Skip to content

Commit

Permalink
added IP parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sarmadsalman-RS committed Oct 2, 2023
1 parent 581b1a1 commit f4a56bc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions rapidsilicon/ip/dsp_generator/v1_0/dsp_generator_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import argparse
from pathlib import Path
from datetime import datetime
from migen import *

from litex.gen import *
Expand Down Expand Up @@ -277,6 +278,40 @@ def main():
platform = platform,
module = module,
)

# IP_ID Parameter
now = datetime.datetime.now()
my_year = now.year - 2022
year = (bin(my_year)[2:]).zfill(7) # 7-bits # Removing '0b' prefix = [2:]
month = (bin(now.month)[2:]).zfill(4) # 4-bits
day = (bin(now.day)[2:]).zfill(5) # 5-bits
mod_hour = now.hour % 12 # 12 hours Format
hour = (bin(mod_hour)[2:]).zfill(4) # 4-bits
minute = (bin(now.minute)[2:]).zfill(6) # 6-bits
second = (bin(now.second)[2:]).zfill(6) # 6-bits

# Concatenation for IP_ID Parameter
ip_id = ("{}{}{}{}{}{}").format(year, day, month, hour, minute, second)
ip_id = ("32'h{}").format(hex(int(ip_id,2))[2:])

# IP_VERSION parameter
# Base _ Major _ Minor
ip_version = "00000000_00000000_0000000000000001"
ip_version = ("32'h{}").format(hex(int(ip_version, 2))[2:])

wrapper = os.path.join(args.build_dir, "rapidsilicon", "ip", "dsp_generator", "v1_0", args.build_name, "src",args.build_name+".v")
new_lines = []
with open (wrapper, "r") as file:
lines = file.readlines()
for i, line in enumerate(lines):
if ("module {}".format(args.build_name)) in line:
new_lines.append("module {} #(\n\tparameter IP_TYPE \t\t= \"DSPGEN\",\n\tparameter IP_VERSION \t= {}, \n\tparameter IP_ID \t\t= {}\n)\n(".format(args.build_name, ip_version, ip_id))
else:
new_lines.append(line)

with open(os.path.join(wrapper), "w") as file:
file.writelines(new_lines)

build_name = args.build_name.rsplit( ".", 1 )[ 0 ]
file = os.path.join(args.build_dir, "rapidsilicon/ip/dsp_generator/v1_0", build_name, "sim/dsp_test.v")
file = Path(file)
Expand Down
35 changes: 35 additions & 0 deletions rapidsilicon/ip/fifo_generator/v1_0/fifo_generator_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import argparse
from pathlib import Path
from datetime import datetime
import math

from litex_wrapper.fifo_litex_generator import *
Expand Down Expand Up @@ -197,6 +198,40 @@ def main():
platform = platform,
module = module
)

# IP_ID Parameter
now = datetime.datetime.now()
my_year = now.year - 2022
year = (bin(my_year)[2:]).zfill(7) # 7-bits # Removing '0b' prefix = [2:]
month = (bin(now.month)[2:]).zfill(4) # 4-bits
day = (bin(now.day)[2:]).zfill(5) # 5-bits
mod_hour = now.hour % 12 # 12 hours Format
hour = (bin(mod_hour)[2:]).zfill(4) # 4-bits
minute = (bin(now.minute)[2:]).zfill(6) # 6-bits
second = (bin(now.second)[2:]).zfill(6) # 6-bits

# Concatenation for IP_ID Parameter
ip_id = ("{}{}{}{}{}{}").format(year, day, month, hour, minute, second)
ip_id = ("32'h{}").format(hex(int(ip_id,2))[2:])

# IP_VERSION parameter
# Base _ Major _ Minor
ip_version = "00000000_00000000_0000000000000001"
ip_version = ("32'h{}").format(hex(int(ip_version, 2))[2:])

wrapper = os.path.join(args.build_dir, "rapidsilicon", "ip", "fifo_generator", "v1_0", args.build_name, "src",args.build_name+".v")
new_lines = []
with open (wrapper, "r") as file:
lines = file.readlines()
for i, line in enumerate(lines):
if ("module {}".format(args.build_name)) in line:
new_lines.append("module {} #(\n\tparameter IP_TYPE \t\t= \"FIFOGEN\",\n\tparameter IP_VERSION \t= {}, \n\tparameter IP_ID \t\t= {}\n)\n(".format(args.build_name, ip_version, ip_id))
else:
new_lines.append(line)

with open(os.path.join(wrapper), "w") as file:
file.writelines(new_lines)

build_name = args.build_name.rsplit( ".", 1 )[ 0 ]
file = os.path.join(args.build_dir, "rapidsilicon/ip/fifo_generator/v1_0", build_name, "sim/testbench.v")
file = Path(file)
Expand Down

0 comments on commit f4a56bc

Please sign in to comment.