URL
https://opencores.org/ocsvn/avuc/avuc/trunk
Subversion Repositories avuc
[/] [avuc/] [trunk/] [example/] [max_mem.usm] - Rev 8
Compare with Previous | Blame | View Log
&$clock clk
&$data_bus_min_width 0
&$entity max_mem
&$header
---------------------------------------------------------------------------------------
-- Copyright 2008 by USM
-- Description: Search for the maximum number in a memory.
---------------------------------------------------------------------------------------
&$include
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
library work;
use work.avuc_pkg.all;
&$generic
&$port
-- Main clock:
clk: in std_logic;
-- Memory data bus:
mem_data: in std_logic_vector(7 downto 0);
-- Memory address bus:
mem_addr: out std_logic_vector(6 downto 0);
&$sig_declaration
-- Temporary maximum number
signal max_number: std_logic_vector(mem_data'range);
-- Copy of output:
signal mem_addr_s: std_logic_vector(mem_addr'range);
&$opcode_def mem_addr_s
&$mem_addr_ini
&$cycle_def 1
mem_addr_s <= (others => '0');
&$mem_addr_inc
&$cycle_def 1
mem_addr_s <= mem_addr_s + 1;
&$end_opcode_def
&$opcode_def max_number
&$max_number_ini
&$cycle_def 1
max_number <= (others => '0');
&$max_number_assign
&$cycle_def 1
max_number <= mem_data;
&$end_opcode_def
&$jump_opcode_def
&$condition jump_if_mem_addr_eq_last
mem_addr_s = (mem_addr_s'range => '1')
&$condition jump_if_mem_data_lt_max
mem_data < max_number
&$prog_code
mem_addr_ini
max_number_ini
loop1: jump_if_mem_data_lt_max next1
max_number_assign
next1: jump_if_mem_addr_eq_last end
mem_addr_inc
jump loop1
&$extra_code
mem_addr <= mem_addr_s;
&$end_usm