1
0
forked from tanchou/Verilog
This commit is contained in:
Gamenight77
2025-05-02 15:51:18 +02:00
parent 0faab53c30
commit f5e73d7379
105 changed files with 707398 additions and 1 deletions

View File

@@ -0,0 +1,101 @@
#!
:ivl_version "13.0 (devel)" "(s20250103-24-g6088a26d7-dirty)";
:ivl_delay_selection "TYPICAL";
:vpi_time_precision - 12;
:vpi_module "c:\tools\OSS-CA~1\lib\ivl\system.vpi";
:vpi_module "c:\tools\OSS-CA~1\lib\ivl\vhdl_sys.vpi";
:vpi_module "c:\tools\OSS-CA~1\lib\ivl\vhdl_textio.vpi";
:vpi_module "c:\tools\OSS-CA~1\lib\ivl\v2005_math.vpi";
:vpi_module "c:\tools\OSS-CA~1\lib\ivl\va_math.vpi";
:vpi_module "c:\tools\OSS-CA~1\lib\ivl\v2009.vpi";
S_00000173f996e8a0 .scope package, "$unit" "$unit" 2 1;
.timescale 0 0;
S_00000173f996ea30 .scope module, "example1_tb" "example1_tb" 3 4;
.timescale -9 -12;
v00000173f996bd00_0 .var "clk", 0 0;
v00000173f996bda0_0 .net "strobe", 0 0, v00000173f996b350_0; 1 drivers
S_00000173f9967280 .scope module, "count" "example1" 3 12, 4 2 0, S_00000173f996ea30;
.timescale -9 -12;
.port_info 0 /INPUT 1 "clk";
.port_info 1 /OUTPUT 1 "strobe";
P_00000173f9a28a80 .param/l "WIDTH" 1 4 7, +C4<00000000000000000000000000000100>;
v00000173f996ebc0_0 .net "clk", 0 0, v00000173f996bd00_0; 1 drivers
v00000173f996a0c0_0 .var "count", 3 0;
v00000173f996b350_0 .var "strobe", 0 0;
E_00000173f9a28880 .event posedge, v00000173f996ebc0_0;
E_00000173f9a28380 .event anyedge, v00000173f996a0c0_0;
.scope S_00000173f9967280;
T_0 ;
%pushi/vec4 0, 0, 4;
%store/vec4 v00000173f996a0c0_0, 0, 4;
%end;
.thread T_0, $init;
.scope S_00000173f9967280;
T_1 ;
Ewait_0 .event/or E_00000173f9a28380, E_0x0;
%wait Ewait_0;
%load/vec4 v00000173f996a0c0_0;
%and/r;
%store/vec4 v00000173f996b350_0, 0, 1;
%jmp T_1;
.thread T_1, $push;
.scope S_00000173f9967280;
T_2 ;
%wait E_00000173f9a28880;
%load/vec4 v00000173f996a0c0_0;
%addi 1, 0, 4;
%assign/vec4 v00000173f996a0c0_0, 0;
%jmp T_2;
.thread T_2;
.scope S_00000173f996ea30;
T_3 ;
%pushi/vec4 0, 0, 1;
%store/vec4 v00000173f996bd00_0, 0, 1;
%end;
.thread T_3, $init;
.scope S_00000173f996ea30;
T_4 ;
T_4.0 ;
%delay 5000, 0;
%load/vec4 v00000173f996bd00_0;
%nor/r;
%store/vec4 v00000173f996bd00_0, 0, 1;
%jmp T_4.0;
T_4.1 ;
%end;
.thread T_4;
.scope S_00000173f996ea30;
T_5 ;
%vpi_call/w 3 17 "$dumpfile", "counter_tb.vcd" {0 0 0};
%vpi_call/w 3 18 "$dumpvars", 32'sb00000000000000000000000000000000, S_00000173f996ea30 {0 0 0};
%end;
.thread T_5;
.scope S_00000173f996ea30;
T_6 ;
%delay 1000000, 0;
%vpi_call/w 3 27 "$finish" {0 0 0};
%end;
.thread T_6;
.scope S_00000173f996ea30;
T_7 ;
%delay 500000, 0;
%vpi_call/w 3 32 "$finish" {0 0 0};
%end;
.thread T_7;
.scope S_00000173f996ea30;
T_8 ;
%wait E_00000173f9a28880;
%load/vec4 v00000173f996bda0_0;
%flag_set/vec4 8;
%jmp/0xz T_8.0, 8;
%vpi_call/w 3 36 "$display", "Strobe" {0 0 0};
T_8.0 ;
%jmp T_8;
.thread T_8;
# The file index is used to find the file name in the following table.
:file_names 5;
"N/A";
"<interactive>";
"-";
"example1_tb.v";
"example1.v";

View File

@@ -0,0 +1,71 @@
`timescale 1ns/1ps
`default_nettype none
// Simple counter_reg with synchronous reset (and no load)
//
module counter #(
parameter WIDTH = 8,
parameter INITIAL_VALUE = 8'h0f
) (
input wire clk, // global clock
input wire reset, // synchronous reset signal
input wire en, // enable signal
output reg strobe // output strobe
);
initial strobe = 0;
reg[WIDTH-1:0] counter_reg = INITIAL_VALUE;
always @(posedge clk) begin
if (reset) begin
counter_reg <= INITIAL_VALUE;
end
else if (en) begin
strobe <= 0;
if (counter_reg == 0)
counter_reg <= INITIAL_VALUE;
else begin
if (counter_reg == 1)
strobe <= 1;
counter_reg <= counter_reg - 1;
end
end
end
`ifdef FORMAL
reg f_past_valid = 0;
always @* f_past_valid = !$initstate;
always @* begin
assume (counter_reg <= INITIAL_VALUE);
end
always @(posedge clk) begin
// if ($initstate) begin
// assume(counter_reg==INITIAL_VALUE);
// end
// if (!$initstate && $past(en)==1 && !$past(reset)) begin
if (f_past_valid && $past(en)==1 && !$past(reset)) begin
if (counter_reg < INITIAL_VALUE)
assert (counter_reg == $past(counter_reg) - 1);
else begin
assert(counter_reg == INITIAL_VALUE && $past(counter_reg)==0);
end
end
end
`endif
`ifdef VERIFIC
//internal_check: assert property (@(posedge clk)(counter_reg==11)|=>(counter_reg==10));
//assert property (@(posedge clk)(counter_reg==11 && en && !reset)|=>(counter_reg==10));
`endif
endmodule

View File

@@ -0,0 +1,286 @@
$date
Sat Apr 26 17:20:46 2025
$end
$version
Icarus Verilog
$end
$timescale
1ps
$end
$scope module example1_tb $end
$var wire 1 ! strobe $end
$var reg 1 " clk $end
$scope module count $end
$var wire 1 " clk $end
$var parameter 32 # WIDTH $end
$var reg 4 $ count [3:0] $end
$var reg 1 ! strobe $end
$upscope $end
$upscope $end
$enddefinitions $end
$comment Show the parameter values. $end
$dumpall
b100 #
$end
#0
$dumpvars
b0 $
0"
0!
$end
#5000
b1 $
1"
#10000
0"
#15000
b10 $
1"
#20000
0"
#25000
b11 $
1"
#30000
0"
#35000
b100 $
1"
#40000
0"
#45000
b101 $
1"
#50000
0"
#55000
b110 $
1"
#60000
0"
#65000
b111 $
1"
#70000
0"
#75000
b1000 $
1"
#80000
0"
#85000
b1001 $
1"
#90000
0"
#95000
b1010 $
1"
#100000
0"
#105000
b1011 $
1"
#110000
0"
#115000
b1100 $
1"
#120000
0"
#125000
b1101 $
1"
#130000
0"
#135000
b1110 $
1"
#140000
0"
#145000
1!
b1111 $
1"
#150000
0"
#155000
0!
b0 $
1"
#160000
0"
#165000
b1 $
1"
#170000
0"
#175000
b10 $
1"
#180000
0"
#185000
b11 $
1"
#190000
0"
#195000
b100 $
1"
#200000
0"
#205000
b101 $
1"
#210000
0"
#215000
b110 $
1"
#220000
0"
#225000
b111 $
1"
#230000
0"
#235000
b1000 $
1"
#240000
0"
#245000
b1001 $
1"
#250000
0"
#255000
b1010 $
1"
#260000
0"
#265000
b1011 $
1"
#270000
0"
#275000
b1100 $
1"
#280000
0"
#285000
b1101 $
1"
#290000
0"
#295000
b1110 $
1"
#300000
0"
#305000
1!
b1111 $
1"
#310000
0"
#315000
0!
b0 $
1"
#320000
0"
#325000
b1 $
1"
#330000
0"
#335000
b10 $
1"
#340000
0"
#345000
b11 $
1"
#350000
0"
#355000
b100 $
1"
#360000
0"
#365000
b101 $
1"
#370000
0"
#375000
b110 $
1"
#380000
0"
#385000
b111 $
1"
#390000
0"
#395000
b1000 $
1"
#400000
0"
#405000
b1001 $
1"
#410000
0"
#415000
b1010 $
1"
#420000
0"
#425000
b1011 $
1"
#430000
0"
#435000
b1100 $
1"
#440000
0"
#445000
b1101 $
1"
#450000
0"
#455000
b1110 $
1"
#460000
0"
#465000
1!
b1111 $
1"
#470000
0"
#475000
0!
b0 $
1"
#480000
0"
#485000
b1 $
1"
#490000
0"
#495000
b10 $
1"
#500000
0"

View File

@@ -0,0 +1,32 @@
`default_nettype none
module example1 (
input wire clk, // global clock
output reg strobe // output strobe
);
localparam WIDTH=4;
reg[WIDTH-1:0] count = 0;
always_comb begin
strobe = &count;
end
always_ff @(posedge clk) begin
count <= count + 1;
end
endmodule
/*
module top_module (
input in1,
input in2,
input in3,
output out);
always_comb
out = ~(in1 ^ in2) ^ in3;
endmodule
*/

View File

@@ -0,0 +1,39 @@
`timescale 1ns/1ps
`default_nettype none
module example1_tb ();
reg clk = 0;
initial forever #5 clk = !clk;
wire strobe;
example1 count (.clk(clk), .strobe(strobe));
initial begin
`ifdef VCD_DUMP
$dumpfile("counter_tb.vcd");
$dumpvars(0,example1_tb);
`endif
end
initial begin
`ifdef END_TIME
#`END_TIME $finish();
`else
#1000 $finish();
`endif
end
initial begin
#500 $finish();
end
always @(posedge clk) begin
if (strobe) $display("Strobe");
end
endmodule