mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-18 06:39:03 +00:00
ice40: Implement simple SB_HFOSC and SB_LFOSC for simulation
This doesn't use all the features, notably trim, nor does it simulate the first 100us, instead working on the first cycle
This commit is contained in:
parent
6965abeefa
commit
e2409c3335
|
@ -2678,6 +2678,37 @@ module SB_HFOSC(
|
|||
);
|
||||
parameter TRIM_EN = "0b0";
|
||||
parameter CLKHF_DIV = "0b00";
|
||||
|
||||
`ifndef BLACKBOX
|
||||
// 96mhz hidden clock
|
||||
reg hidden_clock = 0;
|
||||
|
||||
// all 4 options for the clock divider
|
||||
reg [3:0] divisions = 0;
|
||||
|
||||
always begin
|
||||
while (CLKHFPU) begin
|
||||
#5208 hidden_clock = 0;
|
||||
#5208 hidden_clock = 1;
|
||||
end
|
||||
// when PowerUp is deasserted, wait to resynchronize the clock on it's edge
|
||||
@(posedge CLKHFPU);
|
||||
end
|
||||
|
||||
// TODO: simulate the 100us of "not yet ready"/power stability early on
|
||||
|
||||
always @(posedge hidden_clock) begin
|
||||
divisions <= divisions + 1;
|
||||
end
|
||||
|
||||
localparam index = CLKHF_DIV == "0b00" ? 0 :
|
||||
CLKHF_DIV == "0b01" ? 1 :
|
||||
CLKHF_DIV == "0b10" ? 2 :
|
||||
CLKHF_DIV == "0b11" ? 3 : 0;
|
||||
|
||||
assign CLKHF = CLKHFEN && CLKHFPU && divisions[index];
|
||||
|
||||
`endif
|
||||
endmodule
|
||||
|
||||
(* blackbox *)
|
||||
|
@ -2686,6 +2717,23 @@ module SB_LFOSC(
|
|||
input CLKLFEN,
|
||||
output CLKLF
|
||||
);
|
||||
|
||||
`ifndef BLACKBOX
|
||||
reg clock = 0;
|
||||
always begin
|
||||
while (CLKLFPU) begin
|
||||
#100000000 clock = 0;
|
||||
#100000000 clock = 1;
|
||||
end
|
||||
// when PowerUp is deasserted, wait to resynchronize the clock on its edge
|
||||
@(posedge CLKLFPU);
|
||||
end
|
||||
|
||||
// TODO: simulate the 100us of "not yet ready"/power stability early on
|
||||
|
||||
assign CLKLF = CLKLFEN && CLKLFPU && clock;
|
||||
|
||||
`endif
|
||||
endmodule
|
||||
|
||||
(* blackbox *)
|
||||
|
|
Loading…
Reference in a new issue