-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from yrabbit/bandgap-z1
Implement power saving primitive BANDGAP
- Loading branch information
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module top ( | ||
input key_i, | ||
output [`LEDS_NR-1:0] led | ||
); | ||
|
||
wire clk; | ||
|
||
`ifdef OSC_TYPE_OSC | ||
OSC osc( | ||
.OSCOUT(clk) | ||
); | ||
`elsif OSC_TYPE_OSCZ | ||
OSCZ osc( | ||
.OSCEN(1'b1), | ||
.OSCOUT(clk) | ||
); | ||
`elsif OSC_TYPE_OSCF | ||
OSCF osc( | ||
.OSCEN(1'b1), | ||
.OSCOUT(clk), | ||
.OSCOUT30M() | ||
); | ||
`elsif OSC_TYPE_OSCH | ||
OSCH osc( | ||
.OSCOUT(clk) | ||
); | ||
`endif | ||
defparam osc.FREQ_DIV=16; | ||
|
||
wire key = key_i ^ `INV_BTN; | ||
|
||
reg [25:0] ctr_q; | ||
wire [25:0] ctr_d; | ||
|
||
// Sequential code (flip-flop) | ||
always @(posedge clk) begin | ||
ctr_q <= ctr_d; | ||
end | ||
|
||
BANDGAP bandgap( | ||
.BGEN(key) | ||
); | ||
|
||
|
||
// Combinational code (boolean logic) | ||
assign ctr_d = ctr_q + 1'b1; | ||
assign led = {ctr_q[25:25-(`LEDS_NR - 2)], |ctr_q[25-(`LEDS_NR - 1):25-(`LEDS_NR)] }; | ||
|
||
endmodule |