-- Dump of fbLFSR -- Generated on Mon, 05 Aug 2013 04:30:09 GMT -- by http://127.0.0.1/index.dev.html -- yasep/ASM/YASMed.js version 2013/07/31-dev Library work; use work.yasep_definitions.all; use work.yasep_utils.all; Library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity SynchRam16 is port( clk, reset, en: in std_logic := '0'; NPC: in SLVAI; RAM_out: out SLV16); end SynchRam16; architecture fbLFSR of SynchRam16 is signal latched_addr : SLVAI := (SLVAI'range=>'0'); type RAM_array_type is array(0 to 23) of SLV16; constant RAM_array : RAM_array_type := ( -- ; fbLFSR : fill the screen with a pseudo-random colour -- .name fbLFSR -- ; .profile microYASEP32 -- .profile auto -- YASEP32 -- ; Registers affected : -- ; R1 : LFSR (colour) -- ; R2 : polynomial -- ; R3 : counter -- ; A1 : loop -- ; A2 : screen (address register) -- ; associated with D2 (data register) "0011000100001001", "0000000000000000", -- mov 65536 R3 -- ; address of framebuffer: "1101001000001001", "0000000000000000", -- mov 20000h A2 "0001000000001001", "1010000000000000", -- mov A000h R1 "0001000110001001", "0000000011111111", -- movh FFh R1 ; #00A0FF : sky blue -- ; initialise R2 with the LFSR polynomial: "0010000000001001", "0001110110110111", -- mov 1DB7h R2 ; LSB "0010001010001001", "0000010011000001", -- movh 04C1h R2 ; MSB "0100000000010111", "00001111000---1-", -- add 4 PC A1 -- ;;;;; start of the loop ;;;;; -- ; generate a pseudo-random bit : "0001000100010100", -- ADD R1 R1 ; shift R1 by one position -- ; to the left and copy the most -- ; significant bit into the carry flag -- ; If the carry flag is set, apply the polynomial "0010000111010011", "00000001100---0-", -- xor R2 R1 CARRY -- ; write the colour into the framebuffer "0001110000001000", -- mov R1 D2 "0100110100010110", -- add 4 A2 -- ; decrement the counter "1111001100010110", -- add -1 R3 -- ; move A1 into PC if R3 is not equal to 0 "1111000000001011", "00110000001---0-", -- mov A1 PC NZ R3 -- ;;;;;; end of loop ;;;;;; "0001----00000110", -- HALT 1 "1111111111111111" ); begin assert YASEP_SIZE=0 report "YASEP_SIZE is not 0" severity warning; process(clk, en) begin if rising_edge(clk) and en='0' then latched_addr <= NPC; end if; end process; process(latched_addr ,reset) variable adr: integer; begin if reset/='1' then RAM_out <= (RAM_out'range=>'0'); else adr := safe_to_integer(latched_addr); if adr < 0 or adr >= RAM_array'length then report " Accessing instruction beyond limit at " & integer'image(adr); RAM_out <= (RAM_out'range=>'1'); else RAM_out <= RAM_array(adr); end if; end if; end process; end fbLFSR;