first commit

This commit is contained in:
2026-11-24 22:49:06 +01:00
commit 20a1830bc6
10 changed files with 872 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
iverilog -g2012 -Wall -o simu_counter counter_4b.sv tb_counter_4b.sv
vvp simu_counter
gtkwave counter_4b.vcd
+71
View File
@@ -0,0 +1,71 @@
#! /c/Source/iverilog-install/bin/vvp
:ivl_version "14.0 (devel)";
:ivl_delay_selection "TYPICAL";
:vpi_time_precision + 0;
:vpi_module "C:\iverilog\lib\ivl\system.vpi";
:vpi_module "C:\iverilog\lib\ivl\vhdl_sys.vpi";
:vpi_module "C:\iverilog\lib\ivl\vhdl_textio.vpi";
:vpi_module "C:\iverilog\lib\ivl\v2005_math.vpi";
:vpi_module "C:\iverilog\lib\ivl\va_math.vpi";
:vpi_module "C:\iverilog\lib\ivl\v2009.vpi";
S_000001D4B05FE960 .scope package, "$unit" "$unit" 2 1;
.timescale 0 0;
S_000001D4B05FEAF0 .scope module, "counter_4b" "counter_4b" 3 1;
.timescale 0 0;
.port_info 0 /INPUT 1 "clk";
.port_info 1 /INPUT 1 "rst";
.port_info 2 /INPUT 1 "en";
.port_info 3 /INPUT 1 "load";
.port_info 4 /INPUT 4 "data_in";
.port_info 5 /OUTPUT 4 "count";
.port_info 6 /OUTPUT 1 "max_tick";
L_000001D4B067C3C8 .functor BUFT 1, C4<1111>, C4<0>, C4<0>, C4<0>;
v000001D4B05FEC80_0 .net/2u *"_ivl_0", 3 0, L_000001D4B067C3C8; 1 drivers
o000001D4B063AF88 .functor BUFZ 1, c4<z>; HiZ drive
v000001D4B05FED20_0 .net "clk", 0 0, o000001D4B063AF88; 0 drivers
v000001D4B06350D0_0 .var "count", 3 0;
o000001D4B063AFE8 .functor BUFZ 4, c4<zzzz>; HiZ drive
v000001D4B0635170_0 .net "data_in", 3 0, o000001D4B063AFE8; 0 drivers
o000001D4B063B018 .functor BUFZ 1, c4<z>; HiZ drive
v000001D4B0635210_0 .net "en", 0 0, o000001D4B063B018; 0 drivers
o000001D4B063B048 .functor BUFZ 1, c4<z>; HiZ drive
v000001D4B06352B0_0 .net "load", 0 0, o000001D4B063B048; 0 drivers
v000001D4B0635350_0 .net "max_tick", 0 0, L_000001D4B0635490; 1 drivers
o000001D4B063B0A8 .functor BUFZ 1, c4<z>; HiZ drive
v000001D4B06353F0_0 .net "rst", 0 0, o000001D4B063B0A8; 0 drivers
E_000001D4B0637860 .event posedge, v000001D4B05FED20_0;
L_000001D4B0635490 .cmp/eq 4, v000001D4B06350D0_0, L_000001D4B067C3C8;
.scope S_000001D4B05FEAF0;
T_0 ;
%wait E_000001D4B0637860;
%load/vec4 v000001D4B06353F0_0;
%flag_set/vec4 8;
%jmp/0xz T_0.0, 8;
%pushi/vec4 0, 0, 4;
%assign/vec4 v000001D4B06350D0_0, 0;
%jmp T_0.1;
T_0.0 ;
%load/vec4 v000001D4B06352B0_0;
%flag_set/vec4 8;
%jmp/0xz T_0.2, 8;
%load/vec4 v000001D4B0635170_0;
%assign/vec4 v000001D4B06350D0_0, 0;
%jmp T_0.3;
T_0.2 ;
%load/vec4 v000001D4B0635210_0;
%flag_set/vec4 8;
%jmp/0xz T_0.4, 8;
%load/vec4 v000001D4B06350D0_0;
%addi 1, 0, 4;
%assign/vec4 v000001D4B06350D0_0, 0;
T_0.4 ;
T_0.3 ;
T_0.1 ;
%jmp T_0;
.thread T_0;
# The file index is used to find the file name in the following table.
:file_names 4;
"N/A";
"<interactive>";
"-";
"counter_4b.sv";
+25
View File
@@ -0,0 +1,25 @@
`timescale 1ns / 1ps
module counter_4b (
input logic clk,
input logic rst,
input logic en,
input logic load,
input logic [3:0] data_in,
output logic [3:0] count,
output logic max_tick
);
always_ff @(posedge clk) begin
if(rst) begin
count <= 4'b0000;
end else if(load) begin
count <= data_in;
end else if(en) begin
count <= count + 4'd1;
end
end
assign max_tick = (count == 4'b1111);
endmodule
+162
View File
@@ -0,0 +1,162 @@
$date
Tue Nov 24 22:45:57 2026
$end
$version
Icarus Verilog
$end
$timescale
1ps
$end
$scope module tb_counter_4b $end
$var wire 1 ! max_tick $end
$var wire 4 " count [3:0] $end
$var reg 1 # clk $end
$var reg 4 $ data_in [3:0] $end
$var reg 1 % en $end
$var reg 1 & load $end
$var reg 1 ' rst $end
$scope module dut $end
$var wire 1 # clk $end
$var wire 4 ( data_in [3:0] $end
$var wire 1 % en $end
$var wire 1 & load $end
$var wire 1 ' rst $end
$var wire 1 ! max_tick $end
$var reg 4 ) count [3:0] $end
$upscope $end
$upscope $end
$enddefinitions $end
$comment Show the parameter values. $end
$dumpall
$end
#0
$dumpvars
bx )
b0 (
1'
0&
0%
b0 $
0#
bx "
x!
$end
#5000
0!
b0 "
b0 )
1#
#10000
0#
#15000
1#
#20000
0#
#25000
1%
0'
1#
#30000
0#
#35000
b1 "
b1 )
1#
#40000
0#
#45000
b10 "
b10 )
1#
#50000
0#
#55000
b11 "
b11 )
1#
#60000
0#
#65000
b100 "
b100 )
1#
#70000
0#
#75000
b101 "
b101 )
1#
#80000
0#
#85000
b110 "
b110 )
1#
#90000
0#
#95000
b111 "
b111 )
1#
#100000
0#
#105000
b1000 "
b1000 )
1#
#110000
0#
#115000
b1001 "
b1001 )
1#
#120000
0#
#125000
b1010 "
b1010 )
1#
#130000
0#
#135000
b1011 "
b1011 )
1#
#140000
0#
#145000
b1100 "
b1100 )
1#
#150000
0#
#155000
b1101 "
b1101 )
1#
#160000
0#
#165000
b1110 "
b1110 )
1#
#170000
0#
#175000
1!
b1111 "
b1111 )
1#
#180000
0#
#185000
0!
b0 "
b0 )
1#
#190000
0#
#195000
b1 "
b1 )
1#
+122
View File
@@ -0,0 +1,122 @@
#! /c/Source/iverilog-install/bin/vvp
:ivl_version "14.0 (devel)";
:ivl_delay_selection "TYPICAL";
:vpi_time_precision - 12;
:vpi_module "C:\iverilog\lib\ivl\system.vpi";
:vpi_module "C:\iverilog\lib\ivl\vhdl_sys.vpi";
:vpi_module "C:\iverilog\lib\ivl\vhdl_textio.vpi";
:vpi_module "C:\iverilog\lib\ivl\v2005_math.vpi";
:vpi_module "C:\iverilog\lib\ivl\va_math.vpi";
:vpi_module "C:\iverilog\lib\ivl\v2009.vpi";
S_0000022D87A555F0 .scope package, "$unit" "$unit" 2 1;
.timescale 0 0;
S_0000022D87A569A0 .scope module, "tb_counter_4b" "tb_counter_4b" 3 3;
.timescale -9 -12;
v0000022D87A66840_0 .var "clk", 0 0;
v0000022D87A668E0_0 .net "count", 3 0, v0000022D87A6ADD0_0; 1 drivers
v0000022D87ABA4F0_0 .var "data_in", 3 0;
v0000022D87AB9A50_0 .var "en", 0 0;
v0000022D87AB9E10_0 .var "load", 0 0;
v0000022D87AB9D70_0 .net "max_tick", 0 0, L_0000022D87AB9EB0; 1 drivers
v0000022D87ABA590_0 .var "rst", 0 0;
S_0000022D87A6AC40 .scope module, "dut" "counter_4b" 3 14, 4 3 0, S_0000022D87A569A0;
.timescale -9 -12;
.port_info 0 /INPUT 1 "clk";
.port_info 1 /INPUT 1 "rst";
.port_info 2 /INPUT 1 "en";
.port_info 3 /INPUT 1 "load";
.port_info 4 /INPUT 4 "data_in";
.port_info 5 /OUTPUT 4 "count";
.port_info 6 /OUTPUT 1 "max_tick";
L_0000022D87C10088 .functor BUFT 1, C4<1111>, C4<0>, C4<0>, C4<0>;
v0000022D87A55370_0 .net/2u *"_ivl_0", 3 0, L_0000022D87C10088; 1 drivers
v0000022D87A2ED50_0 .net "clk", 0 0, v0000022D87A66840_0; 1 drivers
v0000022D87A6ADD0_0 .var "count", 3 0;
v0000022D87A6AE70_0 .net "data_in", 3 0, v0000022D87ABA4F0_0; 1 drivers
v0000022D87A6AF10_0 .net "en", 0 0, v0000022D87AB9A50_0; 1 drivers
v0000022D87A6AFB0_0 .net "load", 0 0, v0000022D87AB9E10_0; 1 drivers
v0000022D87A6B050_0 .net "max_tick", 0 0, L_0000022D87AB9EB0; alias, 1 drivers
v0000022D87A667A0_0 .net "rst", 0 0, v0000022D87ABA590_0; 1 drivers
E_0000022D87A53FF0 .event posedge, v0000022D87A2ED50_0;
L_0000022D87AB9EB0 .cmp/eq 4, v0000022D87A6ADD0_0, L_0000022D87C10088;
.scope S_0000022D87A6AC40;
T_0 ;
%wait E_0000022D87A53FF0;
%load/vec4 v0000022D87A667A0_0;
%flag_set/vec4 8;
%jmp/0xz T_0.0, 8;
%pushi/vec4 0, 0, 4;
%assign/vec4 v0000022D87A6ADD0_0, 0;
%jmp T_0.1;
T_0.0 ;
%load/vec4 v0000022D87A6AFB0_0;
%flag_set/vec4 8;
%jmp/0xz T_0.2, 8;
%load/vec4 v0000022D87A6AE70_0;
%assign/vec4 v0000022D87A6ADD0_0, 0;
%jmp T_0.3;
T_0.2 ;
%load/vec4 v0000022D87A6AF10_0;
%flag_set/vec4 8;
%jmp/0xz T_0.4, 8;
%load/vec4 v0000022D87A6ADD0_0;
%addi 1, 0, 4;
%assign/vec4 v0000022D87A6ADD0_0, 0;
T_0.4 ;
T_0.3 ;
T_0.1 ;
%jmp T_0;
.thread T_0;
.scope S_0000022D87A569A0;
T_1 ;
%pushi/vec4 0, 0, 1;
%store/vec4 v0000022D87A66840_0, 0, 1;
T_1.0 ;
%delay 5000, 0;
%load/vec4 v0000022D87A66840_0;
%inv;
%store/vec4 v0000022D87A66840_0, 0, 1;
%jmp T_1.0;
T_1.1 ;
%end;
.thread T_1;
.scope S_0000022D87A569A0;
T_2 ;
%vpi_call/w 3 31 "$dumpfile", "counter_4b.vcd" {0 0 0};
%vpi_call/w 3 32 "$dumpvars", 32'sb00000000000000000000000000000000, S_0000022D87A569A0 {0 0 0};
%pushi/vec4 1, 0, 1;
%store/vec4 v0000022D87ABA590_0, 0, 1;
%pushi/vec4 0, 0, 1;
%store/vec4 v0000022D87AB9A50_0, 0, 1;
%pushi/vec4 0, 0, 1;
%store/vec4 v0000022D87AB9E10_0, 0, 1;
%pushi/vec4 0, 0, 4;
%store/vec4 v0000022D87ABA4F0_0, 0, 4;
%delay 20000, 0;
%wait E_0000022D87A53FF0;
%pushi/vec4 0, 0, 1;
%assign/vec4 v0000022D87ABA590_0, 0;
%pushi/vec4 1, 0, 1;
%assign/vec4 v0000022D87AB9A50_0, 0;
%pushi/vec4 15, 0, 32;
T_2.0 %dup/vec4;
%cmpi/s 0, 0, 32;
%jmp/1xz T_2.1, 5;
%jmp/1 T_2.1, 4;
%subi 1, 0, 32;
%wait E_0000022D87A53FF0;
%jmp T_2.0;
T_2.1 ;
%pop/vec4 1;
%delay 20000, 0;
%vpi_call/w 3 49 "$display", "Fin de la simulation." {0 0 0};
%vpi_call/w 3 50 "$finish" {0 0 0};
%end;
.thread T_2;
# The file index is used to find the file name in the following table.
:file_names 5;
"N/A";
"<interactive>";
"-";
"tb_counter_4b.sv";
"counter_4b.sv";
+53
View File
@@ -0,0 +1,53 @@
`timescale 1ns/1ps
module tb_counter_4b;
logic clk;
logic rst;
logic en;
logic load;
logic [3:0] data_in;
logic max_tick;
logic [3:0] count;
counter_4b dut (
.clk(clk),
.rst(rst),
.en(en),
.load(load),
.data_in(data_in),
.max_tick(max_tick),
.count(count)
);
initial begin
clk = 1'b0;
forever #5 clk = ~clk;
end
initial begin
$dumpfile("counter_4b.vcd");
$dumpvars(0, tb_counter_4b);
rst = 1'b1;
en = 1'b0;
load = 1'b0;
data_in = 4'b0000;
#20; // Maintien du reset pendant 2 coups d'horloge
@(posedge clk);
rst <= 1'b0;
en <= 1'b1;
repeat (15) @(posedge clk);
#20;
$display("Fin de la simulation.");
$finish;
end
endmodule
+21
View File
@@ -0,0 +1,21 @@
module shift_reg_4b (
input logic clk,
input logic rst,
input logic en,
input logic in,
output logic out
);
logic [3:0] shift_reg;
always_ff @(posedge clk) begin
if (rst) begin
shift_reg <= 4'b0000;
end else if (en) begin
shift_reg <= {shift_reg[2:0], in};
end
end
assign out = shift_reg[3];
endmodule
+172
View File
@@ -0,0 +1,172 @@
$date
Tue Nov 24 22:08:34 2026
$end
$version
Icarus Verilog
$end
$timescale
1ps
$end
$scope module tb_shift_reg_4b $end
$var wire 1 ! out $end
$var reg 1 " clk $end
$var reg 1 # en $end
$var reg 1 $ in $end
$var reg 1 % rst $end
$scope module dut $end
$var wire 1 " clk $end
$var wire 1 # en $end
$var wire 1 $ in $end
$var wire 1 % rst $end
$var wire 1 ! out $end
$var reg 4 & shift_reg [3:0] $end
$upscope $end
$upscope $end
$enddefinitions $end
$comment Show the parameter values. $end
$dumpall
$end
#0
$dumpvars
bx &
1%
0$
0#
0"
x!
$end
#5000
0!
b0 &
1"
#10000
0"
#15000
1"
#20000
0"
#25000
1$
1#
0%
1"
#30000
0"
#35000
0$
b1 &
1"
#40000
0"
#45000
b10 &
1"
#50000
0"
#55000
b100 &
1"
#60000
0"
#65000
1!
b1000 &
1"
#70000
0"
#75000
0!
b0 &
1"
#80000
0"
#85000
1$
1"
#90000
0"
#95000
0$
b1 &
1"
#100000
0"
#105000
b10 &
1$
1"
#110000
0"
#115000
b101 &
1"
#120000
0"
#125000
1!
b1011 &
0$
1"
#130000
0"
#135000
0!
0#
b110 &
1"
#140000
0"
#145000
1"
#150000
0"
#155000
1"
#160000
0"
#165000
1#
1"
#170000
0"
#175000
1!
b1100 &
1"
#180000
0"
#185000
b1000 &
1"
#190000
0"
#195000
0!
b0 &
1"
#200000
0"
#205000
1"
#210000
0"
#215000
1%
1"
#220000
0"
#225000
1"
#230000
0"
#235000
0%
1"
#240000
0"
#245000
1"
#250000
0"
#255000
1"
+165
View File
@@ -0,0 +1,165 @@
#! /c/Source/iverilog-install/bin/vvp
:ivl_version "14.0 (devel)";
:ivl_delay_selection "TYPICAL";
:vpi_time_precision - 12;
:vpi_module "C:\iverilog\lib\ivl\system.vpi";
:vpi_module "C:\iverilog\lib\ivl\vhdl_sys.vpi";
:vpi_module "C:\iverilog\lib\ivl\vhdl_textio.vpi";
:vpi_module "C:\iverilog\lib\ivl\v2005_math.vpi";
:vpi_module "C:\iverilog\lib\ivl\va_math.vpi";
:vpi_module "C:\iverilog\lib\ivl\v2009.vpi";
S_000001946E405540 .scope package, "$unit" "$unit" 2 1;
.timescale 0 0;
S_000001946E405120 .scope module, "tb_shift_reg_4b" "tb_shift_reg_4b" 3 3;
.timescale -9 -12;
v000001946E406F50_0 .var "clk", 0 0;
v000001946E4074F0_0 .var "en", 0 0;
v000001946E406D70_0 .var "in", 0 0;
v000001946E406FF0_0 .net "out", 0 0, L_000001946E406EB0; 1 drivers
v000001946E4071D0_0 .var "rst", 0 0;
S_000001946E407C90 .scope module, "dut" "shift_reg_4b" 3 13, 4 1 0, S_000001946E405120;
.timescale 0 0;
.port_info 0 /INPUT 1 "clk";
.port_info 1 /INPUT 1 "rst";
.port_info 2 /INPUT 1 "en";
.port_info 3 /INPUT 1 "in";
.port_info 4 /OUTPUT 1 "out";
v000001946E407810_0 .net "clk", 0 0, v000001946E406F50_0; 1 drivers
v000001946E4076D0_0 .net "en", 0 0, v000001946E4074F0_0; 1 drivers
v000001946E4078B0_0 .net "in", 0 0, v000001946E406D70_0; 1 drivers
v000001946E407130_0 .net "out", 0 0, L_000001946E406EB0; alias, 1 drivers
v000001946E407270_0 .net "rst", 0 0, v000001946E4071D0_0; 1 drivers
v000001946E406E10_0 .var "shift_reg", 3 0;
E_000001946E421570 .event posedge, v000001946E407810_0;
L_000001946E406EB0 .part v000001946E406E10_0, 3, 1;
.scope S_000001946E407C90;
T_0 ;
%wait E_000001946E421570;
%load/vec4 v000001946E407270_0;
%flag_set/vec4 8;
%jmp/0xz T_0.0, 8;
%pushi/vec4 0, 0, 4;
%assign/vec4 v000001946E406E10_0, 0;
%jmp T_0.1;
T_0.0 ;
%load/vec4 v000001946E4076D0_0;
%flag_set/vec4 8;
%jmp/0xz T_0.2, 8;
%load/vec4 v000001946E406E10_0;
%parti/s 3, 0, 2;
%load/vec4 v000001946E4078B0_0;
%concat/vec4; draw_concat_vec4
%assign/vec4 v000001946E406E10_0, 0;
T_0.2 ;
T_0.1 ;
%jmp T_0;
.thread T_0;
.scope S_000001946E405120;
T_1 ;
%pushi/vec4 0, 0, 1;
%store/vec4 v000001946E406F50_0, 0, 1;
T_1.0 ;
%delay 5000, 0;
%load/vec4 v000001946E406F50_0;
%inv;
%store/vec4 v000001946E406F50_0, 0, 1;
%jmp T_1.0;
T_1.1 ;
%end;
.thread T_1;
.scope S_000001946E405120;
T_2 ;
%vpi_call/w 3 30 "$dumpfile", "shift_reg_4b.vcd" {0 0 0};
%vpi_call/w 3 31 "$dumpvars", 32'sb00000000000000000000000000000000, S_000001946E405120 {0 0 0};
%pushi/vec4 1, 0, 1;
%store/vec4 v000001946E4071D0_0, 0, 1;
%pushi/vec4 0, 0, 1;
%store/vec4 v000001946E4074F0_0, 0, 1;
%pushi/vec4 0, 0, 1;
%store/vec4 v000001946E406D70_0, 0, 1;
%delay 20000, 0;
%wait E_000001946E421570;
%pushi/vec4 0, 0, 1;
%assign/vec4 v000001946E4071D0_0, 0;
%pushi/vec4 1, 0, 1;
%assign/vec4 v000001946E4074F0_0, 0;
%pushi/vec4 1, 0, 1;
%assign/vec4 v000001946E406D70_0, 0;
%wait E_000001946E421570;
%pushi/vec4 0, 0, 1;
%assign/vec4 v000001946E406D70_0, 0;
%pushi/vec4 5, 0, 32;
T_2.0 %dup/vec4;
%cmpi/s 0, 0, 32;
%jmp/1xz T_2.1, 5;
%jmp/1 T_2.1, 4;
%subi 1, 0, 32;
%wait E_000001946E421570;
%jmp T_2.0;
T_2.1 ;
%pop/vec4 1;
%pushi/vec4 1, 0, 1;
%assign/vec4 v000001946E406D70_0, 0;
%wait E_000001946E421570;
%pushi/vec4 0, 0, 1;
%assign/vec4 v000001946E406D70_0, 0;
%wait E_000001946E421570;
%pushi/vec4 1, 0, 1;
%assign/vec4 v000001946E406D70_0, 0;
%wait E_000001946E421570;
%pushi/vec4 1, 0, 1;
%assign/vec4 v000001946E406D70_0, 0;
%wait E_000001946E421570;
%pushi/vec4 0, 0, 1;
%assign/vec4 v000001946E406D70_0, 0;
%wait E_000001946E421570;
%pushi/vec4 0, 0, 1;
%assign/vec4 v000001946E4074F0_0, 0;
%pushi/vec4 3, 0, 32;
T_2.2 %dup/vec4;
%cmpi/s 0, 0, 32;
%jmp/1xz T_2.3, 5;
%jmp/1 T_2.3, 4;
%subi 1, 0, 32;
%wait E_000001946E421570;
%jmp T_2.2;
T_2.3 ;
%pop/vec4 1;
%pushi/vec4 1, 0, 1;
%assign/vec4 v000001946E4074F0_0, 0;
%pushi/vec4 5, 0, 32;
T_2.4 %dup/vec4;
%cmpi/s 0, 0, 32;
%jmp/1xz T_2.5, 5;
%jmp/1 T_2.5, 4;
%subi 1, 0, 32;
%wait E_000001946E421570;
%jmp T_2.4;
T_2.5 ;
%pop/vec4 1;
%pushi/vec4 1, 0, 1;
%assign/vec4 v000001946E4071D0_0, 0;
%pushi/vec4 2, 0, 32;
T_2.6 %dup/vec4;
%cmpi/s 0, 0, 32;
%jmp/1xz T_2.7, 5;
%jmp/1 T_2.7, 4;
%subi 1, 0, 32;
%wait E_000001946E421570;
%jmp T_2.6;
T_2.7 ;
%pop/vec4 1;
%pushi/vec4 0, 0, 1;
%assign/vec4 v000001946E4071D0_0, 0;
%delay 20000, 0;
%vpi_call/w 3 74 "$display", "Fin de la simulation." {0 0 0};
%vpi_call/w 3 75 "$finish" {0 0 0};
%end;
.thread T_2;
# The file index is used to find the file name in the following table.
:file_names 5;
"N/A";
"<interactive>";
"-";
"tb_shift_reg_4b.sv";
"shift_reg_4b.sv";
+78
View File
@@ -0,0 +1,78 @@
`timescale 1ns / 1ps
module tb_shift_reg_4b;
// Signaux de test reliés au module (DUT : Device Under Test)
logic clk;
logic rst;
logic en;
logic in;
logic out;
// Instanciation du registre à décalage 4 bits
shift_reg_4b dut (
.clk(clk),
.rst(rst),
.en(en),
.in(in),
.out(out)
);
// Génération de l'horloge : période de 10 ns (100 MHz)
initial begin
clk = 1'b0;
forever #5 clk = ~clk;
end
// Scénario de stimulation
initial begin
// Configuration pour l'export des chronogrammes (Icarus Verilog / GTKWave)
$dumpfile("shift_reg_4b.vcd");
$dumpvars(0, tb_shift_reg_4b);
// 1. Initialisation et Reset actif
rst = 1'b1;
en = 1'b0;
in = 1'b0;
#20; // Maintien du reset pendant 2 coups d'horloge
// 2. Relâchement du reset et activation (en = 1)
@(posedge clk);
rst <= 1'b0;
en <= 1'b1;
// 3. Injection d'une impulsion '1' d'un coup d'horloge
// Elle doit ressortir sur 'out' exactement 4 coups d'horloge plus tard
in <= 1'b1;
@(posedge clk);
in <= 1'b0;
// Attente de 5 coups d'horloge pour observer la sortie
repeat (5) @(posedge clk);
// 4. Test d'une séquence de bits : 1 -> 0 -> 1 -> 1
in <= 1'b1; @(posedge clk);
in <= 1'b0; @(posedge clk);
in <= 1'b1; @(posedge clk);
in <= 1'b1; @(posedge clk);
in <= 1'b0;
// 5. Test du gel via 'en = 0' en plein milieu du décalage
@(posedge clk);
en <= 1'b0; // Le registre doit conserver son état
repeat (3) @(posedge clk);
en <= 1'b1; // Reprise du décalage
repeat (5) @(posedge clk);
// 6. Test d'un reset en cours de fonctionnement
rst <= 1'b1;
repeat (2) @(posedge clk);
rst <= 1'b0;
#20;
$display("Fin de la simulation.");
$finish;
end
endmodule