URL
https://opencores.org/ocsvn/zpu/zpu/trunk
Subversion Repositories zpu
Compare Revisions
- This comparison shows the changes necessary to convert path
/zpu/trunk/zpu
- from Rev 94 to Rev 95
- ↔ Reverse comparison
Rev 94 → Rev 95
/example/hello world/helloworld.vhd_header
0,0 → 1,62
-- ZPU |
-- |
-- Copyright 2004-2009 oharboe - Oyvind Harboe - oyvind.harboe@zylin.com |
-- |
-- The FreeBSD license |
-- |
-- Redistribution and use in source and binary forms, with or without |
-- modification, are permitted provided that the following conditions |
-- are met: |
-- |
-- 1. Redistributions of source code must retain the above copyright |
-- notice, this list of conditions and the following disclaimer. |
-- 2. Redistributions in binary form must reproduce the above |
-- copyright notice, this list of conditions and the following |
-- disclaimer in the documentation and/or other materials |
-- provided with the distribution. |
-- |
-- THIS SOFTWARE IS PROVIDED BY THE ZPU PROJECT ``AS IS'' AND ANY |
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
-- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
-- ZPU PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
-- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
-- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-- |
-- The views and conclusions contained in the software and documentation |
-- are those of the authors and should not be interpreted as representing |
-- official policies, either expressed or implied, of the ZPU Project. |
|
library ieee; |
use ieee.std_logic_1164.all; |
use ieee.numeric_std.all; |
|
|
library work; |
use work.zpu_config.all; |
use work.zpupkg.all; |
|
entity dualport_ram is |
port (clk : in std_logic; |
memAWriteEnable : in std_logic; |
memAAddr : in std_logic_vector(maxAddrBitBRAM downto minAddrBit); |
memAWrite : in std_logic_vector(wordSize-1 downto 0); |
memARead : out std_logic_vector(wordSize-1 downto 0); |
memBWriteEnable : in std_logic; |
memBAddr : in std_logic_vector(maxAddrBitBRAM downto minAddrBit); |
memBWrite : in std_logic_vector(wordSize-1 downto 0); |
memBRead : out std_logic_vector(wordSize-1 downto 0)); |
end dualport_ram; |
|
architecture dualport_ram_arch of dualport_ram is |
|
|
type ram_type is array(natural range 0 to ((2**(maxAddrBitBRAM+1))/4)-1) of std_logic_vector(wordSize-1 downto 0); |
|
shared variable ram : ram_type := |
( |
/example/hello world/hello.c
0,0 → 1,46
/* |
* Small hello world example, does not use printf() |
*/ |
#include <stdio.h> |
|
int j; |
int k; |
|
int main(int argc, char **argv) |
{ |
int i; |
for (i=0; i< 10; i++) |
{ |
puts("Hello Xorld 1\n"); |
puts("Hello Xorld 2\n"); |
j=-4; |
if ((j>>1)!=-2) |
{ |
abort(); |
} |
|
k=10; |
if (k*j!=-40) |
{ |
abort(); |
} |
|
j=10; |
k=10000000; |
if (k*j!=100000000) |
{ |
abort(); |
} |
|
j=0x80000000; |
k=0xffffffff; |
if (j>k) |
{ |
abort(); |
} |
} |
if (i!=10) |
{ |
abort(); |
} |
} |
/example/hello world/zpuromgen
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
example/hello world/zpuromgen
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: example/hello world/zpuromgen.exe
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: example/hello world/zpuromgen.exe
===================================================================
--- example/hello world/zpuromgen.exe (nonexistent)
+++ example/hello world/zpuromgen.exe (revision 95)
example/hello world/zpuromgen.exe
Property changes :
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: example/hello world/zpuromgen.c
===================================================================
--- example/hello world/zpuromgen.c (nonexistent)
+++ example/hello world/zpuromgen.c (revision 95)
@@ -0,0 +1,64 @@
+// zpuromgen.c
+//
+// Program to turn a binary file into a VHDL lookup table.
+// by Adam Pierce
+// 29-Feb-2008
+//
+// This software is free to use by anyone for any purpose.
+//
+// To build:
+//
+// gcc -Wall zpuromgen.c -o zpuromgen
+
+#include
+#include
+#include
+#include
+#include
+
+
+int main(int argc, char **argv)
+{
+ u_int8_t opcode[4];
+ int fd;
+ int addr = 0;
+ ssize_t s;
+
+// Check the user has given us an input file.
+ if(argc < 2)
+ {
+ printf("Usage: %s \n\n", argv[0]);
+ return 1;
+ }
+
+// Open the input file.
+ fd = open(argv[1], 0);
+ if(fd == -1)
+ {
+ perror("File Open");
+ return 2;
+ }
+
+ while(1)
+ {
+ // Read 32 bits.
+ s = read(fd, opcode, 4);
+ if(s == -1)
+ {
+ perror("File read");
+ return 3;
+ }
+
+ if(s == 0)
+ break; // End of file.
+
+ // Output to STDOUT.
+ printf("%6d => x\"%02x%02x%02x%02x\",\n",
+ addr++, opcode[0], opcode[1],
+ opcode[2], opcode[3]);
+ }
+
+ close(fd);
+ return 0;
+}
+
Index: example/hello world/build.sh
===================================================================
--- example/hello world/build.sh (nonexistent)
+++ example/hello world/build.sh (revision 95)
@@ -0,0 +1,6 @@
+set -e
+zpu-elf-gcc -O3 -phi "`pwd`/hello.c" -o hello.elf -Wl,--relax -Wl,--gc-sections -g
+zpu-elf-objcopy -O binary hello.elf hello.bin
+cat >../helloworld.vhd helloworld.vhd_header
+./zpuromgen hello.bin >>../helloworld.vhd
+cat >>../helloworld.vhd helloworld.vhd_footer
Index: example/hello world/helloworld.vhd_footer
===================================================================
--- example/hello world/helloworld.vhd_footer (nonexistent)
+++ example/hello world/helloworld.vhd_footer (revision 95)
@@ -0,0 +1,37 @@
+ others => x"00000000"
+);
+
+begin
+
+process (clk)
+begin
+ if (clk'event and clk = '1') then
+ if (memAWriteEnable = '1') and (memBWriteEnable = '1') and (memAAddr=memBAddr) and (memAWrite/=memBWrite) then
+ report "write collision" severity failure;
+ end if;
+
+ if (memAWriteEnable = '1') then
+ ram(to_integer(unsigned(memAAddr))) := memAWrite;
+ memARead <= memAWrite;
+ else
+ memARead <= ram(to_integer(unsigned(memAAddr)));
+ end if;
+ end if;
+end process;
+
+process (clk)
+begin
+ if (clk'event and clk = '1') then
+ if (memBWriteEnable = '1') then
+ ram(to_integer(unsigned(memBAddr))) := memBWrite;
+ memBRead <= memBWrite;
+ else
+ memBRead <= ram(to_integer(unsigned(memBAddr)));
+ end if;
+ end if;
+end process;
+
+
+
+
+end dualport_ram_arch;