langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,20 @@
program main;
initial begin
bit [52:0] a,b,c;
a = 53'h123476547890fe;
b = 53'h06453bdef23ca6;
c = a & b; $display("%h & %h = %h", a,b,c);
c = a | b; $display("%h | %h = %h", a,b,c);
c = a ^ b; $display("%h ^ %h = %h", a,b,c);
c = ~ a; $display("~%h = %h", a, c);
c = a << 5; $display("%h << 5 = %h", a, c);
c = a >> 5; $display("%h >> 5 = %h", a, c);
c = { a[53-23:0], a[52-:23] }; $display("%h rotate-left 23 = %h", a, c);
c = { a[1:0], a[52:2] }; $display("%h rotate-right 2 = %h", a, c);
end
endprogram

View file

@ -0,0 +1,12 @@
module rotate(in, out, shift);
parameter BITS = 32;
parameter SHIFT_BITS = 5;
input [BITS-1:0] in;
output [BITS-1:0] out;
input [SHIFT_BITS-1:0] shift;
always_comb foreach (out[i]) out[i] = in[ (i+shift) % BITS ];
endmodule