URL
https://opencores.org/ocsvn/csa/csa/trunk
Subversion Repositories csa
Compare Revisions
- This comparison shows the changes necessary to convert path
/csa/trunk
- from Rev 50 to Rev 51
- ↔ Reverse comparison
Rev 50 → Rev 51
/bench/makefile
2,7 → 2,7
PROJ_NAME ?= decrypt |
DEBUG ?= y |
|
MODELSIM_DIR=/opt/modeltech/modeltech |
MODELSIM_DIR?=/opt/modeltech/modeltech |
#MODELSIM_DIR=/mnt/new_disk/tool/modeltech/modeltech |
|
ifeq ($(DEBUG),y) |
11,11 → 11,8
CFLAGS= |
endif |
|
all:csa_pli.vpi $(PROJ_NAME).vvp csa_pli_modelsim |
all:csa_pli_modelsim |
|
csa_pli.vpi:csa_pli.c |
-iverilog-vpi $(CFLAGS) --name=csa_pli $^ >/dev/null |
rm -fr csa_pli.o |
|
csa_pli_modelsim:csa_pli.sl |
|
26,53 → 23,8
%.o:%.c |
gcc -c -g -I$(MODELSIM_DIR)/include $^ |
|
test:csa_pli.vpi |
|
%.vvp:%_tb.v ../rtl/%.v |
-iverilog $(CFLAGS) -tvvp -o$@ $^ |
|
test:csa_pli.vpi $(PROJ_NAME).vvp |
vvp -M. -mcsa_pli $(PROJ_NAME).vvp |
|
clean: |
rm -fr *.o *.vvp *.vpi *.log *.key *.sl |
|
key_schedule.vvp:key_schedule_tb.v ../rtl/key_schedule.v ../rtl/key_perm.v |
|
block_decypher.vvp:block_decypher_tb.v ../rtl/block_decypher.v ../rtl/block_perm.v ../rtl/block_sbox.v |
|
decrypt.vvp:decrypt_tb.v \ |
../rtl/decrypt.v \ |
../rtl/key_schedule.v \ |
../rtl/block_perm.v \ |
../rtl/key_perm.v \ |
../rtl/stream_cypher.v \ |
../rtl/sbox1.v \ |
../rtl/sbox2.v \ |
../rtl/sbox3.v \ |
../rtl/sbox4.v \ |
../rtl/sbox5.v \ |
../rtl/sbox6.v \ |
../rtl/sbox7.v \ |
../rtl/sboxes.v \ |
../rtl/stream_iteration.v \ |
../rtl/stream_byte.v \ |
../rtl/stream_8bytes.v \ |
../rtl/block_sbox.v \ |
../rtl/block_decypher.v |
|
stream_cypher.vvp:stream_cypher_tb.v \ |
../rtl/stream_cypher.v \ |
../rtl/sbox1.v \ |
../rtl/sbox2.v \ |
../rtl/sbox3.v \ |
../rtl/sbox4.v \ |
../rtl/sbox5.v \ |
../rtl/sbox6.v \ |
../rtl/sbox7.v \ |
../rtl/sboxes.v \ |
../rtl/stream_iteration.v \ |
../rtl/stream_byte.v \ |
../rtl/stream_8bytes.v |
|
veriwell_test: |
veriwell key_schedule_tb.v ../rtl/key_schedule.v ../rtl/key_perm.v |
/rtl/makefile
10,75 → 10,16
all:$(PROJ_NAME) |
|
key_perm: |
iverilog -S $(VFLAGS) -tnull $@.v |
|
key_schedule: |
iverilog -S $(VFLAGS) -tnull $@.v \ |
key_perm.v |
|
block_decypher: |
iverilog -S $(VFLAGS) -tnull $@.v \ |
block_perm.v \ |
block_sbox.v |
|
group_decrypt: |
iverilog -S $(VFLAGS) -tnull $@.v \ |
stream_cypher.v \ |
stream_8bytes.v \ |
stream_byte.v \ |
stream_iteration.v \ |
sboxes.v \ |
sbox1.v \ |
sbox2.v \ |
sbox3.v \ |
sbox4.v \ |
sbox5.v \ |
sbox6.v \ |
sbox7.v \ |
block_perm.v \ |
block_sbox.v \ |
block_decypher.v |
|
|
stream_cypher: |
iverilog -S $(VFLAGS) -tnull $@.v \ |
sbox1.v \ |
sbox2.v \ |
sbox3.v \ |
sbox4.v \ |
sbox5.v \ |
sbox6.v \ |
sbox7.v \ |
sboxes.v \ |
stream_iteration.v \ |
stream_byte.v \ |
stream_8bytes.v |
|
|
decrypt: |
iverilog -S $(VFLAGS) -tnull $@.v \ |
block_decypher.v \ |
block_perm.v \ |
block_sbox.v \ |
group_decrypt.v \ |
key_cnt.v \ |
key_perm.v \ |
key_schedule.v \ |
sbox1.v \ |
sbox2.v \ |
sbox3.v \ |
sbox4.v \ |
sbox5.v \ |
sbox6.v \ |
sbox7.v \ |
sboxes.v \ |
stream_8bytes.v \ |
stream_byte.v \ |
stream_cypher.v \ |
stream_iteration.v \ |
ts_serial_out.v \ |
ts_sync.v |
|
|
clean: |
|
/makefile
1,8 → 1,21
MODULE:=key_schedule |
TEST_IN_FILE=test_dat/$(MODULE).in |
TEST_TIMES=1 |
DEBUG=n |
|
################################################################################ |
# some environment variables |
################################################################################ |
MODULE := key_schedule # the module name |
TEST_TIMES := 1 # check times |
DEBUG := n # whether debug is enable |
|
|
################################################################################ |
TEST_IN_FILE := test_dat/$(MODULE).in |
|
|
|
################################################################################ |
# depend |
################################################################################ |
|
all:bench sw_sim rtl |
|
.PHONY: rtl |
20,83 → 33,41
@echo compiling sw_sim ... |
@make -s -C sw_sim PROJ_NAME=$(MODULE) DEBUG=$(DEBUG) |
|
synthesis: |
@make -s -C rtl $(MODULE) |
preare_bin_fn = \ |
str="" ; \ |
for ((i=0;i<$1;i=i+1)); \ |
do \ |
n=$$(expr $$RANDOM % 256 ) ; \ |
binstr=$$(echo "ibase=10;obase=16;$$n"|bc) ; \ |
binstr=$$(echo "000: $$binstr " | xxd -r ); \ |
str+=$$binstr ; \ |
done ; \ |
echo -n $$str >$(TEST_IN_FILE) ; |
|
sw: |
@make -s -C sw_sim $(MODULE) |
prepare_block_decypher: |
$(call preare_bin_fn,64) |
|
preare_fn = \ |
str="" ; \ |
for ((i=0;i<$1;i=i+1)); \ |
do \ |
n=$$(expr $$RANDOM % 256 ) ; \ |
binstr=$$(echo "ibase=10;obase=2;$$n"|bc) ; \ |
binstr=$$(echo "$$binstr" | awk ' { n=8-length($$1);for(i=0;i<n;i=i+1) printf "0"; printf $$1; }' ) ; \ |
str=$$(printf "%s%s" $$str $$binstr) ; \ |
done ; \ |
echo $$str >$(TEST_IN_FILE) |
prepare_key_perm: |
$(call preare_bin_fn,8) |
|
preare_bin_fn = \ |
str="" ; \ |
for ((i=0;i<$1;i=i+1)); \ |
do \ |
n=$$(expr $$RANDOM % 256 ) ; \ |
binstr=$$(echo "ibase=10;obase=16;$$n"|bc) ; \ |
binstr=$$(echo "000: $$binstr " | xxd -r ); \ |
str+=$$binstr ; \ |
done ; \ |
echo -n $$str >$(TEST_IN_FILE) ; \ |
|
preare_block_decypher: |
$(call preare_fn,64) |
|
preare_key_perm: |
$(call preare_fn,8) |
|
preare_key_schedule: |
prepare_key_schedule: |
$(call preare_bin_fn,8) |
|
preare_group_decrypt: |
prepare_group_decrypt: |
$(call preare_bin_fn,192) |
|
preare_decrypt: |
#$(call preare_fn,204) # evenkey + oddkey + ts pacted (188) |
str=""; |
cp /dev/null $(TEST_IN_FILE); |
cat decrypted | while read n; \ |
do \ |
n=$$(echo $$n | tr 'a-z' 'A-F'); \ |
binstr=$$(echo "ibase=16;obase=2;$$n"|bc); \ |
binstr=$$(echo "$$binstr" | awk ' { n=8-length($$1);for(i=0;i<n;i=i+1) printf "0"; printf $$1; }' ) ; \ |
str=$$(printf "%s%s" $$str $$binstr) ; \ |
echo -n $$binstr >>$(TEST_IN_FILE); \ |
done |
|
preare_stream_cypher: |
prepare_stream_cypher: |
$(call preare_fn,24) |
|
ifeq ($(DEBUG),y) |
check: |
@(for ((i=0;i<$(TEST_TIMES);i=i+1)) \ |
do \ |
make -s -C sw_sim test PROJ_NAME=$(MODULE); \ |
make -s -C bench test PROJ_NAME=$(MODULE); \ |
diff test_dat/$(MODULE).out.sw test_dat/$(MODULE).out.v ; \ |
done) |
|
else |
check: |
@(for ((i=0;i<$(TEST_TIMES);i=i+1)) \ |
do \ |
make -s preare_$(MODULE); \ |
make -s -C sw_sim test PROJ_NAME=$(MODULE); \ |
make -s -C bench test PROJ_NAME=$(MODULE); \ |
diff test_dat/$(MODULE).out.sw test_dat/$(MODULE).out.v ; \ |
done) |
endif |
|
|
clean: |
echo clean sw_sim |
@make -s -C sw_sim clean |
110,4 → 81,17
@find . -name "*.[ch]" >cscope.files |
@cscope -b |
|
help: |
@echo "avaliable make tagers:" |
@echo "help --- display this help information" |
@echo "prepare_<module_name> --- prepare the input data for test the module" |
@echo "all --- compile the rtl bench and c programs, don't run test" |
@echo "check --- run test" |
@echo "clean --- remove the compiled file" |
@echo "cscope --- gernerate a cscope file for c files( i use vim )" |
@echo "avaliable make variable:" |
@echo "MODULE --- the current module name" |
@echo "TEST_TIMES --- check times" |
@echo "DEBUG --- whether enable debug" |
|
|