Skip to content

Instantly share code, notes, and snippets.

@lovesegfault
Created April 9, 2017 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lovesegfault/39bf179fb88d2e3b32d1aef0838b1a9f to your computer and use it in GitHub Desktop.
Save lovesegfault/39bf179fb88d2e3b32d1aef0838b1a9f to your computer and use it in GitHub Desktop.
signal storage: storage_type := (
-- OPCODE & DR & SA & SB & KNS -- ASSEMBLY CODE
0 => "000011" & "0011" & "0000" & "0000" & "00000000000001", -- SUBI R3,R0,#1
1 => "000011" & "0100" & "0000" & "0000" & "00000000000011", -- SUBI R4,R0,#3
2 => "000011" & "0110" & "0000" & "1111" & "11111111111111", -- SUBI R6,R0,#-1
3 => x"00000000", -- NOP
4 => "000011" & "0001" & "0011" & "0000" & "00000000000001", -- SUBI R1,R3,#1
5 => "010111" & "0010" & "0100" & "0000" & "00000000000111", -- B.EQ R4,R0,#7 ; --> if (R4 = R0) goto END
6 => "000010" & "0010" & "0011" & "0110" & "00000000000000", -- LOOP: SUB R2,R3,R6
7 => "000010" & "0011" & "0000" & "0110" & "00000000000000", -- SUB R3,R0,R6
8 => "000011" & "0100" & "0100" & "1111" & "11111111111111", -- SUBI R4,R4,#-1
9 => "000010" & "0110" & "0000" & "0010" & "00000000000000", -- SUB R6,R0,R2
10 => "000000" & "0001" & "0001" & "0010" & "00000000000000", -- ADD R1,R1,R2
11 => "010111" & "0011" & "0100" & "0000" & "11111111111011", -- B.NE R4,R0,#-5 ; --> if (R4 != R0) goto LOOP
12 => "000010" & "0010" & "0000" & "0001" & "00000000000000", -- SUB R2,R0,R1
13 => "010111" & "0000" & "0000" & "0000" & "00000000000000", -- END: B #0 ; --> END
others => x"00000000" -- NOP
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment