[ :Yana: Index ]

:Yana:YanaMips: YanaMips2011C in HLS C (2016-08-11)

概要 (2016-07-11)

mMIPS(とGXemul)を参考にしたコンピュータ・システムを、高位合成用C言語で実装しています。
YanaMips2011Cでは、例外と割り込みを使用できます。

とりあえず、Vivadoで高位合成できましたし、MicroBoardに続いて、Artyでも実行できました。

構成 (2016-06-11)

まず、命令については、mMIPSのドキュメントから引用しますが、mMIPSの命令を用意して、mMIPSのCコンパイラを使用できるようにします。

さらに、次の命令を追加します。

また、次のレジスタを用意します。

あと、メモリ空間については、GXemulのドキュメントから引用しますが、デバイス「cons」を参考にして、文字を入出力できるようにします。

メモリ空間
0x00000000 - 0x00003FFF
0x00000000: reset vector
0x00000180: other vector
0xB0000000
read: input 8 bits (non-blocking; returns 0 if no char was available)
write: output 8 bits (blocking; ignore if 0)
0xB0000010
read: ignore
write: ignore

なお、この構成でのサンプルは、アドレス「0x00000000」から開始することもあり、GXemulでは実行できませんが、アドレス「0x80000000」から開始するように変更すれば、GXemulで実行できます。

ダウンロード (2016-08-11)

次のアーカイブ・ファイルは、責任や保証を求めずに、個人的に用いてください。

サンプルのビルド (2016-06-11)

次のような環境で、サンプルをビルドできました。

まず、次のようにファイルを用意します。

yana@cygwin ~
$ $HOME/opt/mips-elf/bin/mips-elf-gcc -v
Using built-in specs.
Target: mips-elf
Configured with: /tmp/gccbuild/src/gcc/configure --disable-libssp --target=mips-
elf --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --disable
-shared --enable-newlib -v --enable-multilib --disable-threads --enable-sjlj-exc
eptions --enable-libstdcxx-allocator=malloc --prefix=/tmp/gccbuild/build/install
 --disable-libssp
Thread model: single
gcc version 4.3.2 (GCC)

yana@cygwin ~
$ $HOME/opt/mips-elf/bin/mips-elf-ld -v
GNU ld (GNU Binutils) 2.18

yana@cygwin ~
$ unzip -q mmips_noc.zip

yana@cygwin ~
$ rm mmips_noc/lcc/lccdir/mips-*

yana@cygwin ~
$ ln -s $HOME/opt/mips-elf/bin/mips-elf-as mmips_noc/lcc/lccdir/mips-as

yana@cygwin ~
$ ln -s $HOME/opt/mips-elf/bin/mips-elf-ar mmips_noc/lcc/lccdir/mips-ar

yana@cygwin ~
$ unzip -q yanamips2011cinhlsc20160611.zip

yana@cygwin ~
$

次に、ディレクトリ「mmips_noc/lcc」などで、次のようにビルドします。

サンプルのビルド
mmips_noc/lcc
make clobber
LCCDIR=$HOME/mmips_noc/lcc/lccdir PATH=$LCCDIR:$PATH make
yanamips2011cinhlsc/sample
CC=$HOME/opt/mips-elf/bin/mips-elf-gcc LCCDIR=$HOME/mmips_noc/lcc/lccdir make
$HOME/opt/mips-elf/bin/mips-elf-objcopy -O binary echo echo.bin
perl -e 'binmode(STDIN);while(read(STDIN,$_,4)){printf("0x%08x,\n",unpack("N",$_))}' <echo.bin >../machine/m_main.h

なお、この環境では、ビッグ・エンディアンでビルドできました。

yana@cygwin ~/yanamips2011cinhlsc/sample
$ $HOME/opt/mips-elf/bin/mips-elf-readelf -h -l echo
ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           MIPS R3000
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          52 (bytes into file)
  Start of section headers:          6628 (bytes into file)
  Flags:                             0x1000, o32, mips1
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         2
  Size of section headers:           40 (bytes)
  Number of section headers:         13
  Section header string table index: 10

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0x00000000 0x00000000 0x005d8 0x005d8 R E 0x1000
  LOAD           0x0015d8 0x000015d8 0x000015d8 0x00021 0x00128 RW  0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .text
   01     .data .bss

yana@cygwin ~/yanamips2011cinhlsc/sample
$

Vivadoで高位合成 (2016-06-11)

次のような環境で、Vivadoで高位合成できました。

次のようなファイルを使用して、コマンド・プロンプトから高位合成します。

yana@cygwin ~/yanamips2011cinhlsc/machine
$ cat script.tcl
open_project -reset arty
set_top hlscore
add_files hlscore.c
open_solution -reset solution1
set_part {xc7a35ticsg324-1l} -tool vivado
create_clock -period 10 -name default
csynth_design
exit

yana@cygwin ~/yanamips2011cinhlsc/machine
$

MicroBoardで実行 (2016-08-11)

次のような環境で、MicroBoardで実行できました。

まず、MicroBoardのUARTと接続するシリアル・ポートについて、次のように設定します。

baud rate
115200
data
8
parity
none
stop
1
flow control
none

また、ファイル「AES-S6MB-LX9-G-Other-Master-User-Constraints-File-UCF.zip」としてダウンロードした制約ファイル「Avt_S6LX9_MicroBoard_UCF_110804.ucf」について、基本は有効のようですが、次の部分を無効にします。

さらに、次のようなファイルを使用してMicroBoardで実行すると、シリアル・ポートに「(HDL)」と出力され、文字を入力すると、その文字が出力されます。

ファイル「yanamips2011cinhlsc20160811hdl.zip」としてダウンロードしたファイル
hlscore.v hlsglue.v microboard.v
ファイル「uart2bus_latest.tar.gz」としてダウンロードしたファイル
baud_gen.v uart_rx.v uart_top.v uart_tx.v
ファイル「AES-S6MB-LX9-G-Other-Master-User-Constraints-File-UCF.zip」としてダウンロードして変更したファイル
Avt_S6LX9_MicroBoard_UCF_110804.ucf

次に、ファイル「yanamips2011cinhlsc20160811hdl.zip」としてダウンロードしたファイル「hlscore.v」を削除して、Vivadoで高位合成したファイルを追加してから、MicroBoardで実行します。

Artyで実行 (2016-08-11)

次のような環境で、Artyで実行できました。

まず、ArtyのUARTと接続するシリアル・ポートについて、次のように設定します。

baud rate
115200
data
8
parity
none
stop
1
flow control
none

また、ファイル「Arty_Master.xdc」としてダウンロードした制約ファイルについて、基本は無効のようですが、次の部分を有効にします。

さらに、次のようなファイルを使用してArtyで実行すると、シリアル・ポートに「(HDL)」と出力され、文字を入力すると、その文字が出力されます。

ファイル「yanamips2011cinhlsc20160811hdl.zip」としてダウンロードしたファイル
arty.v hlscore.v hlsglue.v
ファイル「uart2bus_latest.tar.gz」としてダウンロードしたファイル
baud_gen.v uart_rx.v uart_top.v uart_tx.v
ファイル「Arty_Master.xdc」としてダウンロードして変更したファイル
Arty_Master.xdc

次に、ファイル「yanamips2011cinhlsc20160811hdl.zip」としてダウンロードしたファイル「hlscore.v」を削除して、Vivadoで高位合成したファイルを追加してから、Artyで実行します。

Credit

(C) 2016 Yana

Direction: Yana
HTML: Yana
Program: Yana

ChangeLog

2016-08-11 release 2
2016-07-11 release 1
2016-06-11 release 0

[ :Yana: Index ]
(C) 2016 Yana
このサイトについて