IP Design Specification for PYCPLD

IP Design Specification for PYCPLD

 

1. How to make IP into a python module

IP developers need to provide the following documents:

This file naming is python's standard practice for defining local file packages. The contents of this file are as follows

__init__.py
from enc_partial import get_ip_name
from enc_partial import ENC

 enc_partial is the name of the package

get_ip_name is the program name function of this IP

ENC is the name of the python class for this IP

 

2. <ip name>.v

The specific implementation of IP verilog file, refer to the following link:

https://github.com/hakehuang/pycpld/blob/master/ips/ip/enc/enc.v

 

3. env_partial.py

https://github.com/hakehuang/pycpld/blob/master/ips/ip/enc/enc_partial.py

enc_partial.py writes
from .. import base_ip
import os
'''
#an example of io_dic of enc io
{
  ("", 50, "//comments", "pha_out", "enc")
}
'''
#return the class name for query
def get_ip_name():
  return "ENC"
class ENC(base_ip.base_ip):
  ID = "__ENC"
  count = 0
  def __init__(self, io_hash):
    self.dicts = io_hash
    self.count = 1
  def set_alt(self, in_alt):
    return ''
  def matched_id(self, in_key):
    return in_key == self.ID
  def get_pinmux_setting(self):
    return ''
  def get_v_file_list(self):
   #set_global_assignment -name VERILOG_FILE enc.v
    pkgpath = os.path.dirname(__file__)
    return [ os.path.join(pkgpath,"enc.v")]
  def get_module_caller(self):
    return """
enc  enc( .rst_n(rst_n),
          .freq_clk(clk),
          .enable(enable_enc),
       .pha(pha_out),
       .phb(phb_out),
       .home(home_out),
       .index(index_out)
        );
            """
  def get_wire_defines(self):
    return """
wire pha_out;
wire phb_out;
wire home_out;
wire index_out;
          """
  def get_reg_defines(self):
   #additional reg definition
   return "reg enable_enc;\n"
  def module_rest_codes():
    return "enable_enc <= 1'b0;"
  def get_cmd_case_text(self):
    return "enable_enc <= 1'b1;"
  def get_rst_case_text(self):
    return "enable_enc <= 1'b0;"
  def get_dft_case_text(self):
    return "enable_enc <= 1'b0;"
 

In this file, the scripting of the interface that needs to be opened for the verilog IP-to-IP application platform is implemented. Each function in it needs to implement the corresponding interface function. Here, the verilog statement is the script in python.

 

3. How to realize the parameterized configuration of IP pins, we use a yaml file to do:

enc_example.yml

 

ENC:
    IP: __ENC
    CMD: ENC
    pha_out:
        PIN: A34
        DIRECTION: out
    phb_out:
        PIN: A33
        DIRECTION: out
    index_out:
        PIN: CPLD_IO50
        DIRECTION: out

 

ENC: is the start of this IP corresponding to get_ip_name

IP: __ENC indicates that the IP of ENC is applied, corresponding to ID = "__ENC"

CMD: Indicates which serial port command is used to enable IP in the system integration platform

        PIN: A34 indicates the pin defined in the CPLD IO file
        DIRECTION: The direction of the out pin

 

https://github.com/hakehuang/pycpld

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326391405&siteId=291194637