diff --git a/iverilog/tobb/lab5/ayarliSayac.vcd b/iverilog/tobb/lab5/ayarliSayac.vcd index 6607762..102de2e 100644 --- a/iverilog/tobb/lab5/ayarliSayac.vcd +++ b/iverilog/tobb/lab5/ayarliSayac.vcd @@ -229,7 +229,8 @@ b11 ( 1" #70 b111000 ! -b111000 * +b#70 +00 * b0 ( 0" #71 diff --git a/iverilog/tobb/lab6/bibp b/iverilog/tobb/lab6/bibp new file mode 100644 index 0000000..b531c3b --- /dev/null +++ b/iverilog/tobb/lab6/bibp @@ -0,0 +1,286 @@ +#! /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_0x55e76f51ca80 .scope module, "bibpTB" "bibpTB" 2 1; + .timescale 0 0; +P_0x55e76f51cc10 .param/l "N" 0 2 2, +C4<00000000000000000000000000000011>; +v0x55e76f534860_0 .var "A", 8 0; +v0x55e76f534920_0 .net "sonuc", 3 0, v0x55e76f534720_0; 1 drivers +S_0x55e76f51ccb0 .scope module, "uut" "bibp" 2 6, 3 1 0, S_0x55e76f51ca80; + .timescale 0 0; + .port_info 0 /INPUT 9 "buyruk"; + .port_info 1 /OUTPUT 4 "sonuc"; +P_0x55e76f51d420 .param/l "N" 0 3 1, +C4<00000000000000000000000000000011>; +v0x55e76f4d8cf0_0 .var/i "a", 31 0; +v0x55e76f534290_0 .var/i "b", 31 0; +v0x55e76f534370_0 .net "buyruk", 8 0, v0x55e76f534860_0; 1 drivers +v0x55e76f534430_0 .var/i "c", 31 0; +v0x55e76f534510_0 .var/i "count", 31 0; +v0x55e76f534640_0 .var/i "i", 31 0; +v0x55e76f534720_0 .var "sonuc", 3 0; +E_0x55e76f511f90 .event edge, v0x55e76f534370_0; + .scope S_0x55e76f51ccb0; +T_0 ; + %wait E_0x55e76f511f90; + %load/vec4 v0x55e76f534370_0; + %parti/s 3, 6, 4; + %dup/vec4; + %pushi/vec4 0, 0, 3; + %cmp/u; + %jmp/1 T_0.1, 6; + %dup/vec4; + %pushi/vec4 1, 0, 3; + %cmp/u; + %jmp/1 T_0.2, 6; + %dup/vec4; + %pushi/vec4 2, 0, 3; + %cmp/u; + %jmp/1 T_0.3, 6; + %dup/vec4; + %pushi/vec4 3, 0, 3; + %cmp/u; + %jmp/1 T_0.4, 6; + %dup/vec4; + %pushi/vec4 4, 0, 3; + %cmp/u; + %jmp/1 T_0.5, 6; + %dup/vec4; + %pushi/vec4 5, 0, 3; + %cmp/u; + %jmp/1 T_0.6, 6; + %dup/vec4; + %pushi/vec4 6, 0, 3; + %cmp/u; + %jmp/1 T_0.7, 6; + %dup/vec4; + %pushi/vec4 7, 0, 3; + %cmp/u; + %jmp/1 T_0.8, 6; + %pushi/vec4 0, 0, 4; + %store/vec4 v0x55e76f534720_0, 0, 4; + %jmp T_0.9; +T_0.1 ; + %load/vec4 v0x55e76f534370_0; + %parti/s 3, 3, 3; + %pad/u 4; + %load/vec4 v0x55e76f534370_0; + %parti/s 3, 0, 2; + %pad/u 4; + %add; + %store/vec4 v0x55e76f534720_0, 0, 4; + %jmp T_0.9; +T_0.2 ; + %load/vec4 v0x55e76f534370_0; + %parti/s 3, 3, 3; + %pad/u 4; + %load/vec4 v0x55e76f534370_0; + %parti/s 3, 0, 2; + %pad/u 4; + %sub; + %store/vec4 v0x55e76f534720_0, 0, 4; + %jmp T_0.9; +T_0.3 ; + %load/vec4 v0x55e76f534370_0; + %parti/s 3, 3, 3; + %pad/u 4; + %load/vec4 v0x55e76f534370_0; + %parti/s 3, 0, 2; + %pad/u 4; + %and; + %store/vec4 v0x55e76f534720_0, 0, 4; + %jmp T_0.9; +T_0.4 ; + %load/vec4 v0x55e76f534370_0; + %parti/s 3, 3, 3; + %pad/u 4; + %load/vec4 v0x55e76f534370_0; + %parti/s 3, 0, 2; + %pad/u 4; + %or; + %store/vec4 v0x55e76f534720_0, 0, 4; + %jmp T_0.9; +T_0.5 ; + %pushi/vec4 0, 0, 32; + %store/vec4 v0x55e76f534640_0, 0, 32; +T_0.10 ; + %load/vec4 v0x55e76f534640_0; + %cmpi/s 4, 0, 32; + %flag_or 5, 4; + %jmp/0xz T_0.11, 5; + %load/vec4 v0x55e76f534370_0; + %load/vec4 v0x55e76f534640_0; + %part/s 1; + %load/vec4 v0x55e76f534370_0; + %load/vec4 v0x55e76f534640_0; + %addi 1, 0, 32; + %part/s 1; + %cmp/e; + %jmp/0xz T_0.12, 4; + %pushi/vec4 15, 0, 4; + %store/vec4 v0x55e76f534720_0, 0, 4; + %jmp T_0.13; +T_0.12 ; + %pushi/vec4 0, 0, 4; + %store/vec4 v0x55e76f534720_0, 0, 4; +T_0.13 ; + ; show_stmt_assign_vector: Get l-value for compressed += operand + %load/vec4 v0x55e76f534640_0; + %pushi/vec4 1, 0, 32; + %add; + %store/vec4 v0x55e76f534640_0, 0, 32; + %jmp T_0.10; +T_0.11 ; + %jmp T_0.9; +T_0.6 ; + %pushi/vec4 0, 0, 4; + %store/vec4 v0x55e76f534720_0, 0, 4; + %pushi/vec4 0, 0, 32; + %store/vec4 v0x55e76f4d8cf0_0, 0, 32; +T_0.14 ; + %load/vec4 v0x55e76f4d8cf0_0; + %cmpi/s 6, 0, 32; + %jmp/0xz T_0.15, 5; + %load/vec4 v0x55e76f534370_0; + %load/vec4 v0x55e76f4d8cf0_0; + %part/s 1; + %pad/u 32; + %cmpi/e 1, 0, 32; + %jmp/0xz T_0.16, 4; + %pushi/vec4 15, 0, 4; + %store/vec4 v0x55e76f534720_0, 0, 4; +T_0.16 ; + ; show_stmt_assign_vector: Get l-value for compressed += operand + %load/vec4 v0x55e76f4d8cf0_0; + %pushi/vec4 1, 0, 32; + %add; + %store/vec4 v0x55e76f4d8cf0_0, 0, 32; + %jmp T_0.14; +T_0.15 ; + %jmp T_0.9; +T_0.7 ; + %pushi/vec4 0, 0, 32; + %store/vec4 v0x55e76f534510_0, 0, 32; + %pushi/vec4 0, 0, 32; + %store/vec4 v0x55e76f534290_0, 0, 32; +T_0.18 ; + %load/vec4 v0x55e76f534290_0; + %cmpi/s 6, 0, 32; + %jmp/0xz T_0.19, 5; + %load/vec4 v0x55e76f534370_0; + %load/vec4 v0x55e76f534290_0; + %part/s 1; + %pad/u 32; + %cmpi/e 1, 0, 32; + %jmp/0xz T_0.20, 4; + %load/vec4 v0x55e76f534510_0; + %addi 1, 0, 32; + %store/vec4 v0x55e76f534510_0, 0, 32; +T_0.20 ; + ; show_stmt_assign_vector: Get l-value for compressed += operand + %load/vec4 v0x55e76f534290_0; + %pushi/vec4 1, 0, 32; + %add; + %store/vec4 v0x55e76f534290_0, 0, 32; + %jmp T_0.18; +T_0.19 ; + %load/vec4 v0x55e76f534510_0; + %pushi/vec4 2, 0, 32; + %mod/s; + %cmpi/e 0, 0, 32; + %jmp/0xz T_0.22, 4; + %pushi/vec4 15, 0, 4; + %store/vec4 v0x55e76f534720_0, 0, 4; + %jmp T_0.23; +T_0.22 ; + %pushi/vec4 0, 0, 4; + %store/vec4 v0x55e76f534720_0, 0, 4; +T_0.23 ; + %jmp T_0.9; +T_0.8 ; + %pushi/vec4 0, 0, 32; + %store/vec4 v0x55e76f534510_0, 0, 32; + %pushi/vec4 0, 0, 32; + %store/vec4 v0x55e76f534430_0, 0, 32; +T_0.24 ; + %load/vec4 v0x55e76f534430_0; + %cmpi/s 6, 0, 32; + %jmp/0xz T_0.25, 5; + %load/vec4 v0x55e76f534370_0; + %load/vec4 v0x55e76f534430_0; + %part/s 1; + %pad/u 32; + %cmpi/e 1, 0, 32; + %jmp/0xz T_0.26, 4; + %load/vec4 v0x55e76f534510_0; + %addi 1, 0, 32; + %store/vec4 v0x55e76f534510_0, 0, 32; +T_0.26 ; + ; show_stmt_assign_vector: Get l-value for compressed += operand + %load/vec4 v0x55e76f534430_0; + %pushi/vec4 1, 0, 32; + %add; + %store/vec4 v0x55e76f534430_0, 0, 32; + %jmp T_0.24; +T_0.25 ; + %load/vec4 v0x55e76f534510_0; + %pushi/vec4 2, 0, 32; + %mod/s; + %cmpi/e 0, 0, 32; + %jmp/0xz T_0.28, 4; + %pushi/vec4 0, 0, 4; + %store/vec4 v0x55e76f534720_0, 0, 4; + %jmp T_0.29; +T_0.28 ; + %pushi/vec4 15, 0, 4; + %store/vec4 v0x55e76f534720_0, 0, 4; +T_0.29 ; + %jmp T_0.9; +T_0.9 ; + %pop/vec4 1; + %jmp T_0; + .thread T_0, $push; + .scope S_0x55e76f51ca80; +T_1 ; + %vpi_call 2 12 "$dumpfile", "bibp.vcd" {0 0 0}; + %vpi_call 2 13 "$dumpvars" {0 0 0}; + %pushi/vec4 9, 0, 9; + %store/vec4 v0x55e76f534860_0, 0, 9; + %delay 5, 0; + %pushi/vec4 97, 0, 9; + %store/vec4 v0x55e76f534860_0, 0, 9; + %delay 5, 0; + %pushi/vec4 165, 0, 9; + %store/vec4 v0x55e76f534860_0, 0, 9; + %delay 5, 0; + %pushi/vec4 227, 0, 9; + %store/vec4 v0x55e76f534860_0, 0, 9; + %delay 5, 0; + %pushi/vec4 319, 0, 9; + %store/vec4 v0x55e76f534860_0, 0, 9; + %delay 5, 0; + %pushi/vec4 289, 0, 9; + %store/vec4 v0x55e76f534860_0, 0, 9; + %delay 5, 0; + %pushi/vec4 353, 0, 9; + %store/vec4 v0x55e76f534860_0, 0, 9; + %delay 5, 0; + %pushi/vec4 417, 0, 9; + %store/vec4 v0x55e76f534860_0, 0, 9; + %delay 5, 0; + %pushi/vec4 481, 0, 9; + %store/vec4 v0x55e76f534860_0, 0, 9; + %delay 5, 0; + %end; + .thread T_1; +# The file index is used to find the file name in the following table. +:file_names 4; + "N/A"; + ""; + "bibpTB.v"; + "bibp.v"; diff --git a/iverilog/tobb/lab6/bibp.v b/iverilog/tobb/lab6/bibp.v new file mode 100644 index 0000000..3f14d6c --- /dev/null +++ b/iverilog/tobb/lab6/bibp.v @@ -0,0 +1,56 @@ +module bibp #(parameter N = 3) ( + input [(N*2)+2:0] buyruk, + output reg [N:0] sonuc +); + integer i, a, b, c, count; + + always @(buyruk) begin + case (buyruk[(N*2)+2:N*2]) + default: sonuc = {(N+1){1'b0}}; + + 3'b000: sonuc = buyruk[(N*2)-1:(N*2)-3] + buyruk[(N*2)-4:0]; + 3'b001: sonuc = buyruk[(N*2)-1:(N*2)-3] - buyruk[(N*2)-4:0]; + 3'b010: sonuc = buyruk[(N*2)-1:(N*2)-3] & buyruk[(N*2)-4:0]; + 3'b011: sonuc = buyruk[(N*2)-1:(N*2)-3] | buyruk[(N*2)-4:0]; + + 3'b100: begin + for (i = 0; i <= (N*2)-2; i++) + if (buyruk[i] == buyruk[i+1]) + sonuc = {(N+1){1'b1}}; + else + sonuc = {(N+1){1'b0}}; + end + 3'b101: begin + sonuc = {(N+1){1'b0}}; + for (a = 0; a < (N*2); a++) begin + if (buyruk[a] == 1) + sonuc = {(N+1){1'b1}}; + end + end + + 3'b110: begin + count = 0; + for (b = 0; b < (N*2); b++) begin + if (buyruk[b] == 1) + count = count + 1; + end + if (count % 2 == 0) + sonuc = {(N+1){1'b1}}; + else + sonuc = {(N+1){1'b0}}; + end + + 3'b111: begin + count = 0; + for (c = 0; c < (N*2); c++) begin + if (buyruk[c] == 1) + count = count + 1; + end + if (count % 2 == 0) + sonuc = {(N+1){1'b0}}; + else + sonuc = {(N+1){1'b1}}; + end + endcase + end +endmodule diff --git a/iverilog/tobb/lab6/bibp.vcd b/iverilog/tobb/lab6/bibp.vcd new file mode 100644 index 0000000..f8f7441 --- /dev/null +++ b/iverilog/tobb/lab6/bibp.vcd @@ -0,0 +1,81 @@ +$date + Thu Jan 30 06:13:44 2025 +$end +$version + Icarus Verilog +$end +$timescale + 1s +$end +$scope module bibpTB $end +$var wire 4 ! sonuc [3:0] $end +$var reg 9 " A [8:0] $end +$scope module uut $end +$var wire 9 # buyruk [8:0] $end +$var reg 4 $ sonuc [3:0] $end +$var integer 32 % a [31:0] $end +$var integer 32 & b [31:0] $end +$var integer 32 ' c [31:0] $end +$var integer 32 ( count [31:0] $end +$var integer 32 ) i [31:0] $end +$upscope $end +$upscope $end +$enddefinitions $end +#0 +$dumpvars +bx ) +bx ( +bx ' +bx & +bx % +b10 $ +b1001 # +b1001 " +b10 ! +$end +#5 +b11 ! +b11 $ +b1100001 " +b1100001 # +#10 +b100 ! +b100 $ +b10100101 " +b10100101 # +#15 +b111 ! +b111 $ +b11100011 " +b11100011 # +#20 +b1111 ! +b1111 $ +b101 ) +b100111111 " +b100111111 # +#25 +b0 ! +b0 $ +b101 ) +b100100001 " +b100100001 # +#30 +b1111 ! +b1111 $ +b110 % +b101100001 " +b101100001 # +#35 +b110 & +b10 ( +b110100001 " +b110100001 # +#40 +b0 ! +b0 $ +b110 ' +b10 ( +b111100001 " +b111100001 # +#45 diff --git a/iverilog/tobb/lab6/bibpTB.v b/iverilog/tobb/lab6/bibpTB.v new file mode 100644 index 0000000..0663c78 --- /dev/null +++ b/iverilog/tobb/lab6/bibpTB.v @@ -0,0 +1,25 @@ +module bibpTB(); + parameter N = 3; + reg [(N*2)+2:0] A; + wire [N:0] sonuc; + + bibp #(N) uut ( + .buyruk(A), + .sonuc(sonuc) + ); + +initial begin + $dumpfile("bibp.vcd"); + $dumpvars; + A = 9'b000_001_001; #5; + A = 9'b001_100_001; #5; + A = 9'b010_100_101; #5; + A = 9'b011_100_011; #5; + A = 9'b100_111_111; #5; + A = 9'b100_100_001; #5; + A = 9'b101_100_001; #5; + A = 9'b110_100_001; #5; + A = 9'b111_100_001; #5; +end + +endmodule