资源简介
Verilog写的浮点运算单元。
代码片段和文件信息
#!/usr/bin/env python
from chips.api.api import *
import sys
import subprocess
from random import randint
from random import seed
def compile():
subprocess.call(“iverilog -o test_bench_tb file_reader_a.v file_reader_b.v file_writer.v adder.v test_bench.v test_bench_tb.v“ shell=True)
def run_test(stimulus_a stimulus_b):
test = subprocess.Popen(“c_test/test“ stdin=subprocess.PIPE stdout=subprocess.PIPE)
stim_a = open(“stim_a“ ‘w‘);
stim_b = open(“stim_b“ ‘w‘);
expected_responses = []
for a b in zip(stimulus_a stimulus_b):
test.stdin.write(str(a)+“\n“)
test.stdin.write(str(b)+“\n“)
stim_a.write(str(a) + “\n“)
stim_b.write(str(b) + “\n“)
z = int(test.stdout.readline())
expected_responses.append(z)
test.terminate()
stim_a.close()
stim_b.close()
subprocess.call(“./test_bench_tb“ shell=True)
stim_z = open(“resp_z“);
actual_responses = []
for value in stim_z:
actual_responses.append(int(value))
if len(actual_responses) < len(expected_responses):
print “Fail ... not enough results“
exit(0)
for expected actual a b in zip(expected_responses actual_responses stimulus_a stimulus_b):
if(expected != actual):
expected_mantissa = expected & 0x7fffff
expected_exponent = ((expected & 0x7f800000) >> 23) - 127
expected_sign = ((expected & 0x80000000) >> 31)
actual_mantissa = actual & 0x7fffff
actual_exponent = ((actual & 0x7f800000) >> 23) - 127
actual_sign = ((actual & 0x80000000) >> 31)
if expected_exponent == 128 and expected_mantissa != 0:
if(actual_exponent == 128):
passed = True
else:
passed = False
else:
passed = True
if not passed:
print “Fail ... expected:“ hex(expected) “actual:“ hex(actual)
print hex(a)
print “a mantissa:“ a & 0x7fffff
print “a exponent:“ ((a & 0x7f800000) >> 23) - 127
print “a sign:“ ((a & 0x80000000) >> 31)
print hex(b)
print “b mantissa:“ b & 0x7fffff
print “b exponent:“ ((b & 0x7f800000) >> 23) - 127
print “b sign:“ ((b & 0x80000000) >> 31)
print hex(expected)
print “expected mantissa:“ expected & 0x7fffff
print “expected exponent:“ ((expected & 0x7f800000) >> 23) - 127
print “expected sign:“ ((expected & 0x80000000) >> 31)
print hex(actual)
print “actual mantissa:“ actual & 0x7fffff
print “actual exponent:“ ((actual & 0x7f800000) >> 23) - 127
print “actual sign:“ ((actual & 0x80000000) >> 31)
sys.exit(0)
compile()
count = 0
#regression tests
stimulus_a = [0x22cb525a 0x40000000 0x83e73d5c 0xbf9b1e94 0x34082401 0x5e8ef81 0x5c75da81 0x2b017]
stimulus_b = [0xadd79
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-06-21 14:21 fpu-master\
文件 0 2014-06-21 14:21 fpu-master\.gitignore
文件 1061 2014-06-21 14:21 fpu-master\COPYING.txt
文件 1322 2014-06-21 14:21 fpu-master\README.rst
目录 0 2014-06-21 14:21 fpu-master\adder\
文件 35 2014-06-21 14:21 fpu-master\adder\.gitignore
文件 6686 2014-06-21 14:21 fpu-master\adder\adder.v
目录 0 2014-06-21 14:21 fpu-master\adder\c_test\
文件 8496 2014-06-21 14:21 fpu-master\adder\c_test\test
文件 237 2014-06-21 14:21 fpu-master\adder\c_test\test.cpp
文件 7932 2014-06-21 14:21 fpu-master\adder\file_reader_a.v
文件 7932 2014-06-21 14:21 fpu-master\adder\file_reader_b.v
文件 6825 2014-06-21 14:21 fpu-master\adder\file_writer.v
文件 6110 2014-06-21 14:21 fpu-master\adder\run_test.py
文件 0 2014-06-21 14:21 fpu-master\adder\stim_z
文件 1219 2014-06-21 14:21 fpu-master\adder\test_bench.v
文件 316 2014-06-21 14:21 fpu-master\adder\test_bench_tb.v
目录 0 2014-06-21 14:21 fpu-master\divider\
文件 35 2014-06-21 14:21 fpu-master\divider\.gitignore
目录 0 2014-06-21 14:21 fpu-master\divider\c_test\
文件 9603 2014-06-21 14:21 fpu-master\divider\c_test\test
文件 237 2014-06-21 14:21 fpu-master\divider\c_test\test.cpp
文件 7466 2014-06-21 14:21 fpu-master\divider\divider.v
文件 7932 2014-06-21 14:21 fpu-master\divider\file_reader_a.v
文件 7932 2014-06-21 14:21 fpu-master\divider\file_reader_b.v
文件 6825 2014-06-21 14:21 fpu-master\divider\file_writer.v
文件 6039 2014-06-21 14:21 fpu-master\divider\run_test.py
文件 1223 2014-06-21 14:21 fpu-master\divider\test_bench.v
文件 316 2014-06-21 14:21 fpu-master\divider\test_bench_tb.v
目录 0 2014-06-21 14:21 fpu-master\double_adder\
文件 35 2014-06-21 14:21 fpu-master\double_adder\.gitignore
............此处省略121个文件信息
相关资源
- 基于LCD12864的verilog代码
- 四位串行进位加法器
- FPGA实现的联通区识别算法Verilog源代码
- 基于Verilog的低功耗矩阵键盘扫描设计
- 用FPGA实现16位矩阵键盘键值在数码管
- 奇偶分频器设计源码及testbench
- 基于verilog的CMI编码实现
- 基于Verilog的FPGA步进电机控制
- Verilog HDL实现洗衣机功能
- MAC芯片LAN91C111 verilog源码
- DDS信号发生器详细教程和verilog代码
- 十字路口的交通灯控制 Verilog代码详细
- verilog语言实现电子琴
- 基于FPGAVerilog HDL16*16点阵显示字符
- 基于QuartusII的交通灯设计EDA实验(V
- FPGA常用通信总线IIC Verilog代码
- SHA-3 verilogHDL实现
- 改进的Booth算法单精度浮点乘法器源码
- log2and10.sv
- MIPS五级流水线的verilog实现
- ad采样 Verilog
- FPGA的直方图均衡化Verilog代码
- 电梯的verilog代码
- VERILOG实现的4位 ALU 模块实现 5种运算
- I2C slaver 从机 Verilog代码实现
- H.264解码器verilog源代码
- 任意分频的verilog 语言实现(占空比
- 用verilog实现除法器(两种方法
- 正弦波波形数据正弦波周期为2pi,采
- i2c_master verilog源码与testbench
评论
共有 条评论