iverilog
This commit is contained in:
32
iverilog/lab2/HammingDistance/ham.vcd
Normal file
32
iverilog/lab2/HammingDistance/ham.vcd
Normal file
@ -0,0 +1,32 @@
|
||||
$date
|
||||
Tue Oct 8 14:33:58 2024
|
||||
$end
|
||||
$version
|
||||
Icarus Verilog
|
||||
$end
|
||||
$timescale
|
||||
1s
|
||||
$end
|
||||
$scope module htb $end
|
||||
$var reg 8 ! value1 [7:0] $end
|
||||
$var reg 8 " value2 [7:0] $end
|
||||
$scope module uut $end
|
||||
$var wire 8 # value1 [7:0] $end
|
||||
$var wire 8 $ value2 [7:0] $end
|
||||
$var reg 4 % hammingValue [3:0] $end
|
||||
$var integer 32 & i [31:0] $end
|
||||
$upscope $end
|
||||
$upscope $end
|
||||
$enddefinitions $end
|
||||
#0
|
||||
$dumpvars
|
||||
b1000 &
|
||||
b0 %
|
||||
bz $
|
||||
bz #
|
||||
b10111111 "
|
||||
b10110000 !
|
||||
$end
|
||||
#10
|
||||
b10111111 !
|
||||
#20
|
83
iverilog/lab2/HammingDistance/hamming
Normal file
83
iverilog/lab2/HammingDistance/hamming
Normal file
@ -0,0 +1,83 @@
|
||||
#! /usr/bin/vvp
|
||||
:ivl_version "11.0 (stable)";
|
||||
:ivl_delay_selection "TYPICAL";
|
||||
:vpi_time_precision + 0;
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/system.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/vhdl_sys.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/vhdl_textio.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2005_math.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/va_math.vpi";
|
||||
S_0x555b2f00bc50 .scope module, "htb" "htb" 2 1;
|
||||
.timescale 0 0;
|
||||
v0x555b2f01d190_0 .var "value1", 7 0;
|
||||
v0x555b2f01d270_0 .var "value2", 7 0;
|
||||
S_0x555b2f00bde0 .scope module, "uut" "hamming" 2 7, 3 1 0, S_0x555b2f00bc50;
|
||||
.timescale 0 0;
|
||||
.port_info 0 /INPUT 8 "value1";
|
||||
.port_info 1 /INPUT 8 "value2";
|
||||
.port_info 2 /OUTPUT 4 "hammingValue";
|
||||
v0x555b2efd27f0_0 .var "hammingValue", 3 0;
|
||||
v0x555b2efd2c00_0 .var/i "i", 31 0;
|
||||
o0x7f3f4267c078 .functor BUFZ 8, C4<zzzzzzzz>; HiZ drive
|
||||
v0x555b2f01cf70_0 .net "value1", 7 0, o0x7f3f4267c078; 0 drivers
|
||||
o0x7f3f4267c0a8 .functor BUFZ 8, C4<zzzzzzzz>; HiZ drive
|
||||
v0x555b2f01d030_0 .net "value2", 7 0, o0x7f3f4267c0a8; 0 drivers
|
||||
E_0x555b2f00a130 .event edge, v0x555b2f01cf70_0, v0x555b2f01d030_0, v0x555b2efd27f0_0;
|
||||
.scope S_0x555b2f00bde0;
|
||||
T_0 ;
|
||||
%pushi/vec4 0, 0, 32;
|
||||
%store/vec4 v0x555b2efd2c00_0, 0, 32;
|
||||
%end;
|
||||
.thread T_0;
|
||||
.scope S_0x555b2f00bde0;
|
||||
T_1 ;
|
||||
%wait E_0x555b2f00a130;
|
||||
%pushi/vec4 0, 0, 4;
|
||||
%store/vec4 v0x555b2efd27f0_0, 0, 4;
|
||||
%pushi/vec4 0, 0, 32;
|
||||
%store/vec4 v0x555b2efd2c00_0, 0, 32;
|
||||
T_1.0 ;
|
||||
%load/vec4 v0x555b2efd2c00_0;
|
||||
%cmpi/s 8, 0, 32;
|
||||
%jmp/0xz T_1.1, 5;
|
||||
%load/vec4 v0x555b2f01cf70_0;
|
||||
%load/vec4 v0x555b2efd2c00_0;
|
||||
%part/s 1;
|
||||
%load/vec4 v0x555b2f01d030_0;
|
||||
%load/vec4 v0x555b2efd2c00_0;
|
||||
%part/s 1;
|
||||
%cmp/e;
|
||||
%jmp/0xz T_1.2, 4;
|
||||
%load/vec4 v0x555b2efd27f0_0;
|
||||
%addi 1, 0, 4;
|
||||
%store/vec4 v0x555b2efd27f0_0, 0, 4;
|
||||
T_1.2 ;
|
||||
%load/vec4 v0x555b2efd2c00_0;
|
||||
%addi 1, 0, 32;
|
||||
%store/vec4 v0x555b2efd2c00_0, 0, 32;
|
||||
%jmp T_1.0;
|
||||
T_1.1 ;
|
||||
%jmp T_1;
|
||||
.thread T_1, $push;
|
||||
.scope S_0x555b2f00bc50;
|
||||
T_2 ;
|
||||
%vpi_call 2 12 "$dumpfile", "ham.vcd" {0 0 0};
|
||||
%vpi_call 2 13 "$dumpvars" {0 0 0};
|
||||
%pushi/vec4 176, 0, 8;
|
||||
%store/vec4 v0x555b2f01d190_0, 0, 8;
|
||||
%pushi/vec4 191, 0, 8;
|
||||
%store/vec4 v0x555b2f01d270_0, 0, 8;
|
||||
%delay 10, 0;
|
||||
%pushi/vec4 191, 0, 8;
|
||||
%store/vec4 v0x555b2f01d190_0, 0, 8;
|
||||
%pushi/vec4 191, 0, 8;
|
||||
%store/vec4 v0x555b2f01d270_0, 0, 8;
|
||||
%delay 10, 0;
|
||||
%end;
|
||||
.thread T_2;
|
||||
# The file index is used to find the file name in the following table.
|
||||
:file_names 4;
|
||||
"N/A";
|
||||
"<interactive>";
|
||||
"htb.v";
|
||||
"hamming.v";
|
17
iverilog/lab2/HammingDistance/hamming.v
Normal file
17
iverilog/lab2/HammingDistance/hamming.v
Normal file
@ -0,0 +1,17 @@
|
||||
module hamming (
|
||||
input[7:0] value1,
|
||||
input[7:0] value2,
|
||||
output reg[3:0] hammingValue
|
||||
);
|
||||
|
||||
integer i = 0;
|
||||
|
||||
always @(*) begin
|
||||
hammingValue = 0;
|
||||
for(i = 0; i < 8; i = i+1) begin
|
||||
if (value1[i] == value2[i]) begin
|
||||
hammingValue = hammingValue + 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
endmodule
|
19
iverilog/lab2/HammingDistance/htb.v
Normal file
19
iverilog/lab2/HammingDistance/htb.v
Normal file
@ -0,0 +1,19 @@
|
||||
module htb ();
|
||||
|
||||
reg [7:0] value1;
|
||||
reg [7:0] value2;
|
||||
wire [3:0] hammingValue;
|
||||
|
||||
hamming uut (
|
||||
.value1(value1),
|
||||
.value2(value2),
|
||||
.hammingValue(hammingValue)
|
||||
);
|
||||
|
||||
initial begin
|
||||
$dumpfile("ham.vcd");
|
||||
$dumpvars;
|
||||
value1 = 8'hB0; value2 = 8'hBF; #10;
|
||||
value1 = 8'hBF; value2 = 8'hBF; #10;
|
||||
end
|
||||
endmodule
|
Reference in New Issue
Block a user